tdav_session_av.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright (C) 2012-2013 Doubango Telecom <http://www.doubango.org>
  3. * Copyright (C) 2012 Diop Mamadou Ibrahima
  4. *
  5. * This file is part of Open Source Doubango Framework.
  6. *
  7. * DOUBANGO is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * DOUBANGO is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with DOUBANGO.
  19. *
  20. */
  21. /**@file tdav_session_av.h
  22. * @brief Audio/Video/T.140 base Session plugin
  23. */
  24. #ifndef TINYDAV_SESSION_AV_H
  25. #define TINYDAV_SESSION_AV_H
  26. #include "tinydav_config.h"
  27. #include "tinymedia/tmedia_session.h"
  28. #include "tnet_nat.h"
  29. #include "tsk_safeobj.h"
  30. TDAV_BEGIN_DECLS
  31. #define TDAV_SESSION_AV(self) ((tdav_session_av_t*)(self))
  32. typedef struct tdav_session_av_s {
  33. TMEDIA_DECLARE_SESSION;
  34. tsk_bool_t use_ipv6;
  35. tsk_bool_t use_rtcp;
  36. tsk_bool_t use_rtcpmux;
  37. enum tmedia_type_e media_type;
  38. enum tmedia_profile_e media_profile;
  39. enum tmedia_mode_e avpf_mode_set;
  40. enum tmedia_mode_e avpf_mode_neg;
  41. tsk_bool_t is_fb_fir_neg; // a=rtcp-fb:* ccm fir
  42. tsk_bool_t is_fb_nack_neg; // a=rtcp-fb:* nack
  43. tsk_bool_t is_fb_googremb_neg; // a=rtcp-fb:* goog-remb
  44. tsk_bool_t is_fb_doubsjcng_neg; // a=rtcp-fb:* doubs-jcng
  45. tsk_bool_t use_srtp;
  46. tsk_bool_t is_webrtc2sip_mode_enabled;
  47. uint32_t rtp_ssrc;
  48. tmedia_srtp_type_t srtp_type;
  49. tmedia_srtp_mode_t srtp_mode;
  50. struct {
  51. uint64_t count_last_time;
  52. uint64_t count;
  53. } bytes_in;
  54. struct {
  55. uint64_t count_last_time;
  56. uint64_t count;
  57. } bytes_out;
  58. uint64_t time_last_frame_loss_report; // from jb
  59. int32_t bandwidth_max_upload_kbps;
  60. int32_t bandwidth_max_download_kbps;
  61. int32_t fps;
  62. tsk_bool_t congestion_ctrl_enabled;
  63. tmedia_pref_video_size_t pref_size; // output
  64. /* sdp capabilities (RFC 5939) */
  65. struct tdav_sdp_caps_s* sdp_caps;
  66. /* NAT Traversal context */
  67. struct tnet_nat_ctx_s* natt_ctx;
  68. struct tnet_ice_ctx_s* ice_ctx;
  69. char* local_ip;
  70. char* remote_ip;
  71. uint16_t remote_port;
  72. struct tsdp_message_s* remote_sdp;
  73. struct tsdp_message_s* local_sdp;
  74. struct trtp_manager_s* rtp_manager;
  75. struct tmedia_consumer_s* consumer;
  76. struct tmedia_producer_s* producer;
  77. struct {
  78. struct {
  79. tnet_dtls_setup_t setup;
  80. tsk_bool_t connection_new; // "new | existing"
  81. } local;
  82. struct {
  83. tnet_dtls_setup_t setup;
  84. tsk_bool_t connection_new; // "new | existing"
  85. } remote;
  86. } dtls;
  87. struct {
  88. uint8_t payload_type;
  89. struct tmedia_codec_s* codec;
  90. uint16_t seq_num;
  91. uint32_t timestamp;
  92. } ulpfec;
  93. struct {
  94. uint8_t payload_type;
  95. struct tmedia_codec_s* codec;
  96. } red;
  97. struct {
  98. char* reason;
  99. tsk_bool_t is_fatal;
  100. void* tid[1];
  101. } last_error;
  102. // codec's payload type mapping used when bypassing is enabled
  103. struct {
  104. int8_t local;
  105. int8_t remote;
  106. int8_t neg;
  107. } pt_map;
  108. TSK_DECLARE_SAFEOBJ;
  109. }
  110. tdav_session_av_t;
  111. #define TDAV_DECLARE_SESSION_AV tdav_session_av_t __session_av__
  112. int tdav_session_av_init(tdav_session_av_t* self, tmedia_type_t media_type);
  113. tsk_bool_t tdav_session_av_set(tdav_session_av_t* self, const struct tmedia_param_s* param);
  114. tsk_bool_t tdav_session_av_get(tdav_session_av_t* self, struct tmedia_param_s* param);
  115. int tdav_session_av_prepare(tdav_session_av_t* self);
  116. int tdav_session_av_init_encoder(tdav_session_av_t* self, struct tmedia_codec_s* encoder);
  117. int tdav_session_av_start(tdav_session_av_t* self, const struct tmedia_codec_s* best_codec);
  118. int tdav_session_av_stop(tdav_session_av_t* self);
  119. int tdav_session_av_pause(tdav_session_av_t* self);
  120. const tsdp_header_M_t* tdav_session_av_get_lo(tdav_session_av_t* self, tsk_bool_t *updated);
  121. int tdav_session_av_set_ro(tdav_session_av_t* self, const struct tsdp_header_M_s* m, tsk_bool_t *updated);
  122. const tmedia_codec_t* tdav_session_av_get_best_neg_codec(const tdav_session_av_t* self);
  123. const tmedia_codec_t* tdav_session_av_get_red_codec(const tdav_session_av_t* self);
  124. const tmedia_codec_t* tdav_session_av_get_ulpfec_codec(const tdav_session_av_t* self);
  125. int tdav_session_av_deinit(tdav_session_av_t* self);
  126. TDAV_END_DECLS
  127. #endif