tdav_video_jb.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2012 Doubango Telecom <http://www.doubango.org>
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango(DOT)org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. /**@file tdav_video_jb.h
  23. * @brief Video Jitter Buffer
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango(DOT)org>
  26. */
  27. #ifndef TINYDAV_VIDEO_JB_H
  28. #define TINYDAV_VIDEO_JB_H
  29. #include "tinydav_config.h"
  30. #include "tinymedia/tmedia_jitterbuffer.h"
  31. #include "tsk_buffer.h"
  32. #include "tsk_timer.h"
  33. #include "tsk_list.h"
  34. #include "tsk_safeobj.h"
  35. TDAV_BEGIN_DECLS
  36. typedef enum tdav_video_jb_cb_data_type_e {
  37. tdav_video_jb_cb_data_type_rtp,
  38. tdav_video_jb_cb_data_type_fl, // frame lost
  39. tdav_video_jb_cb_data_type_tmfr, // too many frames removed
  40. tdav_video_jb_cb_data_type_fdd, // average frame decoding duration
  41. tdav_video_jb_cb_data_type_fps_changed, // fps changed, detection done using the timestamp
  42. }
  43. tdav_video_jb_cb_data_type_t;
  44. typedef struct tdav_video_jb_cb_data_xs {
  45. tdav_video_jb_cb_data_type_t type;
  46. uint32_t ssrc;
  47. const void* usr_data;
  48. union {
  49. struct {
  50. const struct trtp_rtp_packet_s* pkt;
  51. } rtp;
  52. struct {
  53. uint16_t seq_num;
  54. tsk_size_t count;
  55. } fl;
  56. struct {
  57. uint32_t x_dur; // expected duration in milliseconds
  58. uint32_t a_dur; // actual duration in milliseconds
  59. } fdd;
  60. struct {
  61. uint32_t old;
  62. uint32_t new;
  63. } fps;
  64. };
  65. }
  66. tdav_video_jb_cb_data_xt;
  67. typedef int (*tdav_video_jb_cb_f)(const tdav_video_jb_cb_data_xt* data);
  68. #define TDAV_VIDEO_JB_CB_F(self) ((tdav_video_jb_cb_f)(self))
  69. struct tdav_video_jb_s* tdav_video_jb_create();
  70. int tdav_video_jb_set_callback(struct tdav_video_jb_s* self, tdav_video_jb_cb_f callback, const void* usr_data);
  71. int tdav_video_jb_get_qcong(struct tdav_video_jb_s* self, float* q);
  72. int tdav_video_jb_start(struct tdav_video_jb_s* self);
  73. int tdav_video_jb_put(struct tdav_video_jb_s* self, struct trtp_rtp_packet_s* rtp_pkt);
  74. int tdav_video_jb_stop(struct tdav_video_jb_s* self);
  75. TDAV_END_DECLS
  76. #endif /* TINYDAV_VIDEO_JB_H */