tmedia_converter_video.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (C) 2012 Doubango Telecom <http://www.doubango.org>
  3. *
  4. * This file is part of Open Source Doubango Framework.
  5. *
  6. * DOUBANGO is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * DOUBANGO is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with DOUBANGO.
  18. *
  19. */
  20. /**@file tmedia_converter_video.h
  21. * @brief Video converter plugin (chroma, rotation, scaling, ...)
  22. *
  23. * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
  24. *
  25. */
  26. #ifndef TINYMEDIA_CONVERTER_VIDEO_H
  27. #define TINYMEDIA_CONVERTER_VIDEO_H
  28. #include "tinymedia_config.h"
  29. #include "tmedia_common.h"
  30. TMEDIA_BEGIN_DECLS
  31. /** cast any pointer to @ref tmedia_converter_video_t* object */
  32. #define TMEDIA_CONVERTER_VIDEO(self) ((tmedia_converter_video_t*)(self))
  33. /**Max number of plugins (consumer types) we can create */
  34. #if !defined(TMED_CONVERTER_VIDEO_MAX_PLUGINS)
  35. # define TMED_CONVERTER_VIDEO_MAX_PLUGINS 0x0F
  36. #endif
  37. typedef struct tmedia_converter_video_s {
  38. TSK_DECLARE_OBJECT;
  39. tsk_size_t srcWidth;
  40. tsk_size_t srcHeight;
  41. tsk_size_t dstWidth;
  42. tsk_size_t dstHeight;
  43. tmedia_chroma_t srcChroma;
  44. tmedia_chroma_t dstChroma;
  45. // one shot parameters
  46. int rotation;
  47. tsk_bool_t flip;
  48. tsk_bool_t mirror;
  49. tsk_bool_t scale_rotated_frames;
  50. const struct tmedia_converter_video_plugin_def_s* plugin;
  51. }
  52. tmedia_converter_video_t;
  53. #define TMEDIA_DECLARE_CONVERTER_VIDEO tmedia_converter_video_t __converter__
  54. #define tmedia_converter_video_set(self, _rotation, _flip, _mirror, _scale_rotated_frames) \
  55. if((self)){ \
  56. (self)->rotation = (_rotation); \
  57. (self)->flip = (_flip); \
  58. (self)->mirror = (_mirror); \
  59. (self)->scale_rotated_frames = (_scale_rotated_frames); \
  60. }
  61. #define tmedia_converter_video_set_rotation(self, _rotation) \
  62. if((self)){ \
  63. (self)->rotation = (_rotation); \
  64. }
  65. #define tmedia_converter_video_set_flip(self, _flip) \
  66. if((self)){ \
  67. (self)->flip = (_flip); \
  68. }
  69. #define tmedia_converter_video_set_mirror(self, _mirror) \
  70. if((self)){ \
  71. (self)->mirror = (_mirror); \
  72. }
  73. #define tmedia_converter_video_set_scale_rotated_frames(self, _scale_rotated_frames) \
  74. if((self)){ \
  75. (self)->scale_rotated_frames = (_scale_rotated_frames); \
  76. }
  77. #define tmedia_converter_video_process(_self, _buffer, _size, _output, _output_max_size) \
  78. (_self)->plugin->process((_self), (_buffer), (_size), (_output), (_output_max_size))
  79. /** Virtual table used to define a consumer plugin */
  80. typedef struct tmedia_converter_video_plugin_def_s {
  81. //! object definition used to create an instance of the converter
  82. const tsk_object_def_t* objdef;
  83. int (* init) ( struct tmedia_converter_video_s* self, tsk_size_t srcWidth, tsk_size_t srcHeight, tmedia_chroma_t srcChroma, tsk_size_t dstWidth, tsk_size_t dstHeight, tmedia_chroma_t dstChroma );
  84. tsk_size_t (* process) ( struct tmedia_converter_video_s* self, const void* buffer, tsk_size_t buffer_size, void** output, tsk_size_t* output_max_size );
  85. }
  86. tmedia_converter_video_plugin_def_t;
  87. TINYMEDIA_API tmedia_converter_video_t* tmedia_converter_video_create(tsk_size_t srcWidth, tsk_size_t srcHeight, tmedia_chroma_t srcChroma, tsk_size_t dstWidth, tsk_size_t dstHeight, tmedia_chroma_t dstChroma);
  88. TINYMEDIA_API int tmedia_converter_video_plugin_register(const tmedia_converter_video_plugin_def_t* plugin);
  89. TINYMEDIA_API tsk_size_t tmedia_converter_video_plugin_registry_count();
  90. TINYMEDIA_API int tmedia_converter_video_plugin_unregister(const tmedia_converter_video_plugin_def_t* plugin);
  91. TMEDIA_END_DECLS
  92. #endif /* TINYMEDIA_CONVERTER_VIDEO_H */