tmedia_params.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (C) 2010-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_params.h
  23. * @brief Media parameters used to configure any session or plugin.
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
  26. *
  27. */
  28. #ifndef TINYMEDIA_PARAMS_H
  29. #define TINYMEDIA_PARAMS_H
  30. #include "tinymedia_config.h"
  31. #include "tinymedia/tmedia_common.h"
  32. #include "tsk_list.h"
  33. TMEDIA_BEGIN_DECLS
  34. #define TMEDIA_PARAM(self) ((tmedia_param_t*)(self))
  35. typedef enum tmedia_param_access_type_e {
  36. tmedia_pat_get,
  37. tmedia_pat_set
  38. }
  39. tmedia_param_access_type_t;
  40. typedef enum tmedia_param_plugin_type_e {
  41. tmedia_ppt_consumer,
  42. tmedia_ppt_producer,
  43. tmedia_ppt_codec,
  44. tmedia_ppt_session,
  45. tmedia_ppt_manager
  46. }
  47. tmedia_param_plugin_type_t;
  48. typedef enum tmedia_param_value_type_e {
  49. tmedia_pvt_int32,
  50. tmedia_pvt_bool = tmedia_pvt_int32,
  51. tmedia_pvt_pobject,
  52. tmedia_pvt_pchar,
  53. tmedia_pvt_int64,
  54. }
  55. tmedia_param_value_type_t;
  56. #define TMEDIA_PARAM_VALUE_TYPE_IS_PTR(self) ((self) == tmedia_pvt_pobject || (self) == tmedia_pvt_pchar)
  57. typedef struct tmedia_param_s {
  58. TSK_DECLARE_OBJECT;
  59. tmedia_param_access_type_t access_type;
  60. tmedia_type_t media_type;
  61. tmedia_param_plugin_type_t plugin_type;
  62. tmedia_param_value_type_t value_type;
  63. char* key;
  64. /* Because setting parameters could be deferred
  65. * ==> MUST copy the value for later use.
  66. * e.g. TMEDIA_SESSION_MANAGER_SET_INT32("width", 1234); 1234 will be lost when we exit the block code
  67. */
  68. void* value;
  69. }
  70. tmedia_param_t;
  71. typedef tsk_list_t tmedia_params_L_t; /**< List of @ref tsk_param_t elements. */
  72. #define tmedia_params_create() tsk_list_create()
  73. TINYMEDIA_API tmedia_param_t* tmedia_param_create(tmedia_param_access_type_t access_type,
  74. tmedia_type_t media_type,
  75. tmedia_param_plugin_type_t plugin_type,
  76. tmedia_param_value_type_t value_type,
  77. const char* key,
  78. void* value);
  79. #define tmedia_param_create_get(media_type, plugin_type, value_type, key, value) tmedia_param_create(tmedia_pat_get, (media_type), (plugin_type), (value_type), (key), (value))
  80. #define tmedia_param_create_get_session(media_type, value_type, key, value) tmedia_param_create_get((media_type), tmedia_ppt_session, (value_type), (key), (value))
  81. #define tmedia_param_create_get_codec(media_type, value_type, key, value) tmedia_param_create_get((media_type), tmedia_ppt_codec, (value_type), (key), (value))
  82. #define tmedia_param_create_set(media_type, plugin_type, value_type, key, value) tmedia_param_create(tmedia_pat_set, (media_type), (plugin_type), (value_type), (value))
  83. TINYMEDIA_API tmedia_params_L_t* tmedia_params_create_2(va_list *app);
  84. TINYMEDIA_API int tmedia_params_add_param(tmedia_params_L_t **self,
  85. tmedia_param_access_type_t access_type,
  86. tmedia_type_t media_type,
  87. tmedia_param_plugin_type_t plugin_type,
  88. tmedia_param_value_type_t value_type,
  89. const char* key,
  90. void* value);
  91. TINYMEDIA_GEXTERN const tsk_object_def_t *tmedia_param_def_t;
  92. TMEDIA_END_DECLS
  93. #endif /* TINYMEDIA_PARAMS_H */