tmedia_jitterbuffer.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (C) 2011 Mamadou Diop.
  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 tmedia_jitterbuffer.h
  23. * @brief Audio/Video JitterBuffer Plugin
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
  26. */
  27. #ifndef TINYMEDIA_JITTER_BUFFER_H
  28. #define TINYMEDIA_JITTER_BUFFER_H
  29. #include "tinymedia_config.h"
  30. #include "tinymedia/tmedia_params.h"
  31. #include "tmedia_common.h"
  32. #include "tsk_object.h"
  33. TMEDIA_BEGIN_DECLS
  34. /** cast any pointer to @ref tmedia_jitterbuffer_t* object */
  35. #define TMEDIA_JITTER_BUFFER(self) ((tmedia_jitterbuffer_t*)(self))
  36. /**Max number of plugins (jb types) we can create */
  37. #if !defined(TMED_JITTER_BUFFER_MAX_PLUGINS)
  38. # define TMED_JITTER_BUFFER_MAX_PLUGINS 0x0F
  39. #endif
  40. /** Base object for all JitterBuffers */
  41. typedef struct tmedia_jitterbuffer_s {
  42. TSK_DECLARE_OBJECT;
  43. tsk_bool_t opened;
  44. const struct tmedia_jitterbuffer_plugin_def_s* plugin;
  45. }
  46. tmedia_jitterbuffer_t;
  47. #define TMEDIA_DECLARE_JITTER_BUFFER tmedia_jitterbuffer_t __jitterbuffer__
  48. /** Virtual table used to define a consumer plugin */
  49. typedef struct tmedia_jitterbuffer_plugin_def_s {
  50. //! object definition used to create an instance of the jitterbufferr
  51. const tsk_object_def_t* objdef;
  52. //! the type of the jitter buffer
  53. tmedia_type_t type;
  54. //! full description (usefull for debugging)
  55. const char* desc;
  56. int (*set) (tmedia_jitterbuffer_t* , const tmedia_param_t*);
  57. int (* open) (tmedia_jitterbuffer_t*, uint32_t frame_duration, uint32_t rate, uint32_t channels);
  58. int (* tick) (tmedia_jitterbuffer_t*);
  59. int (* put) (tmedia_jitterbuffer_t*, void* data, tsk_size_t data_size, const tsk_object_t* proto_hdr);
  60. tsk_size_t (* get) (tmedia_jitterbuffer_t*, void* out_data, tsk_size_t out_size);
  61. int (* reset) (tmedia_jitterbuffer_t* );
  62. int (* close) (tmedia_jitterbuffer_t* );
  63. }
  64. tmedia_jitterbuffer_plugin_def_t;
  65. TINYMEDIA_API int tmedia_jitterbuffer_init(tmedia_jitterbuffer_t* self);
  66. TINYMEDIA_API int tmedia_jitterbuffer_set(tmedia_jitterbuffer_t *self, const tmedia_param_t* param);
  67. TINYMEDIA_API int tmedia_jitterbuffer_open(tmedia_jitterbuffer_t* self, uint32_t frame_duration, uint32_t rate, uint32_t channels);
  68. TINYMEDIA_API int tmedia_jitterbuffer_tick(tmedia_jitterbuffer_t* self);
  69. TINYMEDIA_API int tmedia_jitterbuffer_put(tmedia_jitterbuffer_t* self, void* data, tsk_size_t data_size, const tsk_object_t* proto_hdr);
  70. TINYMEDIA_API tsk_size_t tmedia_jitterbuffer_get(tmedia_jitterbuffer_t* self, void* out_data, tsk_size_t out_size);
  71. TINYMEDIA_API int tmedia_jitterbuffer_reset(tmedia_jitterbuffer_t* self);
  72. TINYMEDIA_API int tmedia_jitterbuffer_close(tmedia_jitterbuffer_t* self);
  73. TINYMEDIA_API int tmedia_jitterbuffer_deinit(tmedia_jitterbuffer_t* self);
  74. TINYMEDIA_API int tmedia_jitterbuffer_plugin_register(const tmedia_jitterbuffer_plugin_def_t* plugin);
  75. TINYMEDIA_API int tmedia_jitterbuffer_plugin_unregister();
  76. TINYMEDIA_API int tmedia_jitter_buffer_plugin_unregister_by_type(tmedia_type_t type);
  77. TINYMEDIA_API tmedia_jitterbuffer_t* tmedia_jitterbuffer_create(tmedia_type_t type);
  78. TMEDIA_END_DECLS
  79. #endif /* TINYMEDIA_JITTER_BUFFER_H */