Common.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (C) 2010-2011 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango.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. #ifndef TINYWRAP_COMMON_H
  23. #define TINYWRAP_COMMON_H
  24. #include "tinyWRAP_config.h"
  25. #if defined(__ANDROID__) || defined(ANDROID)
  26. # define dyn_cast static_cast
  27. # define __JNIENV JNIEnv
  28. #else
  29. # define dyn_cast dynamic_cast
  30. # define __JNIENV void
  31. #endif
  32. typedef enum twrap_media_type_e {
  33. // because of Java don't use OR
  34. twrap_media_none = 0x00,
  35. twrap_media_audio = 0x01, // (0x01 << 0)
  36. twrap_media_video = 0x02, // (0x01 << 1)
  37. twrap_media_msrp = 0x04, // (0x01 << 2)
  38. twrap_media_t140 = 0x08, // (0x01 << 3)
  39. twrap_media_bfcp = 0x10, // (0x01 << 4)
  40. twrap_media_bfcp_audio = 0x30, // (0x01 << 5) | twrap_media_bfcp;
  41. twrap_media_bfcp_video = 0x50, // (0x01 << 6) | twrap_media_bfcp;
  42. twrap_media_audiovideo = 0x03, /* @deprecated */
  43. twrap_media_audio_video = twrap_media_audiovideo,
  44. }
  45. twrap_media_type_t;
  46. #if !defined(SWIG)
  47. #include "tinymedia/tmedia_common.h"
  48. struct media_type_bind_s {
  49. twrap_media_type_t twrap;
  50. tmedia_type_t tnative;
  51. };
  52. static const struct media_type_bind_s __media_type_binds[] = {
  53. { twrap_media_msrp, tmedia_msrp },
  54. { twrap_media_audio , tmedia_audio },
  55. { twrap_media_video, tmedia_video },
  56. { twrap_media_audio_video, (tmedia_type_t)(tmedia_audio | tmedia_video) },
  57. { twrap_media_t140, tmedia_t140 },
  58. { twrap_media_bfcp, tmedia_bfcp },
  59. { twrap_media_bfcp_audio, tmedia_bfcp_audio },
  60. { twrap_media_bfcp_video, tmedia_bfcp_video },
  61. };
  62. static const tsk_size_t __media_type_binds_count = sizeof(__media_type_binds)/sizeof(__media_type_binds[0]);
  63. static tmedia_type_t twrap_get_native_media_type(twrap_media_type_t type)
  64. {
  65. tsk_size_t u;
  66. tmedia_type_t t = tmedia_none;
  67. for (u = 0; u < __media_type_binds_count; ++u) {
  68. if ((__media_type_binds[u].twrap & type) == __media_type_binds[u].twrap) {
  69. t = (tmedia_type_t)(t | __media_type_binds[u].tnative);
  70. }
  71. }
  72. return t;
  73. }
  74. static twrap_media_type_t twrap_get_wrapped_media_type(tmedia_type_t type)
  75. {
  76. twrap_media_type_t t = twrap_media_none;
  77. tsk_size_t u;
  78. for (u = 0; u < __media_type_binds_count; ++u) {
  79. if ((__media_type_binds[u].tnative & type) == __media_type_binds[u].tnative) {
  80. t = (twrap_media_type_t)(t | __media_type_binds[u].twrap);
  81. }
  82. }
  83. return t;
  84. }
  85. #endif
  86. #endif /* TINYWRAP_COMMON_H */