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.

62 lines
2.7KB

  1. #ifndef _aio_rtmp_server_h_
  2. #define _aio_rtmp_server_h_
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. typedef struct aio_rtmp_server_t aio_rtmp_server_t;
  9. typedef struct aio_rtmp_session_t aio_rtmp_session_t;
  10. typedef void* aio_rtmp_userptr_t;
  11. struct aio_rtmp_server_handler_t
  12. {
  13. /// aio transport close
  14. /// @param[in] ptr create by onpublish/onplay
  15. void (*onclose)(aio_rtmp_userptr_t ptr);
  16. ///push(client -> server)
  17. ///@param[in] type: live/record/append
  18. ///@return user-defined pointer, for onvideo/onaudio first parameter
  19. aio_rtmp_userptr_t (*onpublish)(void* param, aio_rtmp_session_t* session, const char* app, const char* stream, const char* type);
  20. ///@param[in] data FLV VideoTagHeader + AVCVIDEOPACKET: AVCDecoderConfigurationRecord(ISO 14496-15) / One or more NALUs(four-bytes length + NALU)
  21. int (*onvideo)(aio_rtmp_userptr_t ptr, const void* data, size_t bytes, uint32_t timestamp);
  22. ///@param[in] data FLV AudioTagHeader + AACAUDIODATA: AudioSpecificConfig(14496-3) / Raw AAC frame data in UI8
  23. int (*onaudio)(aio_rtmp_userptr_t ptr, const void* data, size_t bytes, uint32_t timestamp);
  24. ///@param[in] data AMF0/AMF3 script
  25. int (*onscript)(aio_rtmp_userptr_t ptr, const void* data, size_t bytes, uint32_t timestamp);
  26. ///pull(server -> client)
  27. ///@return user-defined pointer, for onpause/onseek/onsend first parameter
  28. aio_rtmp_userptr_t (*onplay)(void* param, aio_rtmp_session_t* session, const char* app, const char* stream, double start, double duration, uint8_t reset);
  29. int (*onpause)(aio_rtmp_userptr_t ptr, int pause, uint32_t ms);
  30. int (*onseek)(aio_rtmp_userptr_t ptr, uint32_t ms);
  31. /// aio_rtmp_server_send_audio/aio_rtmp_server_send_video callback
  32. void (*onsend)(aio_rtmp_userptr_t ptr, size_t bytes);
  33. ///@param[in] param aio_rtmp_server_create param
  34. ///@param[out] duration stream length in seconds
  35. ///@return 0-ok, other-error
  36. int (*ongetduration)(void* param, const char* app, const char* stream, double* duration);
  37. };
  38. aio_rtmp_server_t* aio_rtmp_server_create(const char* ip, int port, struct aio_rtmp_server_handler_t* handler, void* param);
  39. int aio_rtmp_server_destroy(aio_rtmp_server_t* server);
  40. /// @param[in] session oncreate session parameter
  41. int aio_rtmp_server_send_audio(aio_rtmp_session_t* session, const void* flv, size_t bytes, uint32_t timestamp);
  42. int aio_rtmp_server_send_video(aio_rtmp_session_t* session, const void* flv, size_t bytes, uint32_t timestamp);
  43. int aio_rtmp_server_send_script(aio_rtmp_session_t* session, const void* flv, size_t bytes, uint32_t timestamp);
  44. size_t aio_rtmp_server_get_unsend(aio_rtmp_session_t* session);
  45. int aio_rtmp_server_get_addr(aio_rtmp_session_t* session, char ip[65], unsigned short* port);
  46. #ifdef __cplusplus
  47. }
  48. #endif
  49. #endif /* !_aio_rtmp_server_h_ */