You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3KB

  1. #ifndef _pcm_file_source_h_
  2. #define _pcm_file_source_h_
  3. #include "media-source.h"
  4. #include "sys/process.h"
  5. #include "time64.h"
  6. #include "rtp.h"
  7. #include <string>
  8. #include <stdio.h>
  9. class PCMFileSource : public IMediaSource
  10. {
  11. public:
  12. PCMFileSource(const char *file);
  13. virtual ~PCMFileSource();
  14. public:
  15. virtual int Play();
  16. virtual int Pause();
  17. virtual int Seek(int64_t pos);
  18. virtual int SetSpeed(double speed);
  19. virtual int GetDuration(int64_t& duration) const;
  20. virtual int GetSDPMedia(std::string& sdp) const;
  21. virtual int GetRTPInfo(const char* uri, char *rtpinfo, size_t bytes) const;
  22. virtual int SetTransport(const char* track, std::shared_ptr<IRTPTransport> transport);
  23. private:
  24. static void OnRTCPEvent(void* param, const struct rtcp_msg_t* msg);
  25. void OnRTCPEvent(const struct rtcp_msg_t* msg);
  26. int SendRTCP();
  27. static void* RTPAlloc(void* param, int bytes);
  28. static void RTPFree(void* param, void *packet);
  29. static int RTPPacket(void* param, const void *packet, int bytes, uint32_t timestamp, int flags);
  30. private:
  31. FILE* m_fp;
  32. void* m_rtp;
  33. time64_t m_rtp_clock;
  34. time64_t m_rtcp_clock;
  35. std::shared_ptr<IRTPTransport> m_transport;
  36. int m_status;
  37. int64_t m_pos;
  38. double m_speed;
  39. void *m_rtppacker;
  40. unsigned char m_packet[MAX_UDP_PACKET + 14];
  41. };
  42. #endif /* !_pcm_file_source_h_ */