Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

68 linhas
2.8KB

  1. #ifndef _rtmp_client_h_
  2. #define _rtmp_client_h_
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. #if defined(__cplusplus)
  6. extern "C" {
  7. #endif
  8. typedef struct rtmp_client_t rtmp_client_t;
  9. struct rtmp_client_handler_t
  10. {
  11. ///network implementation
  12. ///@return >0-sent bytes, <0-error
  13. int (*send)(void* param, const void* header, size_t len, const void* payload, size_t bytes);
  14. ///VOD only
  15. ///@param[in] video FLV VideoTagHeader + AVCVIDEOPACKET: AVCDecoderConfigurationRecord(ISO 14496-15) / One or more NALUs(four-bytes length + NALU)
  16. ///@param[in] audio FLV AudioTagHeader + AACAUDIODATA: AudioSpecificConfig(14496-3) / Raw AAC frame data in UI8
  17. ///@param[in] script AMF0/AMF3
  18. ///@return 0-ok, other-error
  19. int (*onvideo)(void* param, const void* video, size_t bytes, uint32_t timestamp);
  20. int (*onaudio)(void* param, const void* audio, size_t bytes, uint32_t timestamp);
  21. int (*onscript)(void* param, const void* script, size_t bytes, uint32_t timestamp);
  22. };
  23. /// URL: rtmp://host/app/playpath (TCURL: rtmp://host/app)
  24. /// e.g.: rtmp://live.alivecdn.com/live/hello
  25. /// rtmp_client_create("live", "hello", "rtmp://live.alivecdn.com/live", param, handler)
  26. /// @param[in] appname rtmp app name
  27. /// @param[in] playpath rtmp playpath
  28. /// @param[in] tcurl rtmp url (only host and app name)
  29. rtmp_client_t* rtmp_client_create(const char* appname, const char* playpath, const char* tcurl, void* param, const struct rtmp_client_handler_t* handler);
  30. void rtmp_client_destroy(rtmp_client_t* rtmp);
  31. ///@return 0-ok, other-error
  32. int rtmp_client_input(rtmp_client_t* rtmp, const void* data, size_t bytes);
  33. ///@param[in] publish 0-Publish(push stream to server), 1-LIVE/VOD(pull from server), 2-LIVE only, 3-VOD only
  34. ///@return 0-ok, other-error
  35. int rtmp_client_start(rtmp_client_t* rtmp, int publish);
  36. int rtmp_client_stop(rtmp_client_t* rtmp);
  37. int rtmp_client_pause(rtmp_client_t* rtmp, int pause); // VOD only
  38. int rtmp_client_seek(rtmp_client_t* rtmp, double timestamp); // VOD only
  39. ///@return RTMP_STATE_START(4): push video/audio
  40. int rtmp_client_getstate(rtmp_client_t* rtmp);
  41. ///@param[in] video FLV VideoTagHeader + AVCVIDEOPACKET: AVCDecoderConfigurationRecord(ISO 14496-15) / One or more NALUs(four-bytes length + NALU)
  42. ///@param[in] bytes video data length in bytes
  43. ///@return 0-ok, other-error
  44. int rtmp_client_push_video(rtmp_client_t* rtmp, const void* video, size_t bytes, uint32_t timestamp);
  45. ///@param[in] audio FLV AudioTagHeader + AACAUDIODATA: AudioSpecificConfig(14496-3) / Raw AAC frame data in UI8
  46. ///@param[in] bytes audio data length in bytes
  47. ///@return 0-ok, other-error
  48. int rtmp_client_push_audio(rtmp_client_t* rtmp, const void* audio, size_t bytes, uint32_t timestamp);
  49. ///@param[in] data FLV onMetaData
  50. int rtmp_client_push_script(struct rtmp_client_t* ctx, const void* data, size_t bytes, uint32_t timestamp);
  51. #if defined(__cplusplus)
  52. }
  53. #endif
  54. #endif /* !_rtmp_client_h_ */