VideoFrame.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* Copyright (C) 2011-2013 Doubango Telecom <http://www.doubango.org>
  2. *
  3. * This file is part of Open Source Doubango Framework.
  4. *
  5. * DOUBANGO is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * DOUBANGO is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with DOUBANGO.
  17. */
  18. #ifndef PLUGIN_DSHOW_VIDEOFRAME_H
  19. #define PLUGIN_DSHOW_VIDEOFRAME_H
  20. // Define supported video formats
  21. typedef enum _VIDEOFORMAT {
  22. VIDEOFORMAT_NULL = 0, // 0 x 0 : Null
  23. VIDEOFORMAT_SQCIF, // 128 x 96 : SQCIF
  24. VIDEOFORMAT_QCIF, // 176 x 144 : QCIF
  25. VIDEOFORMAT_QVGA, // 320 x 240 : QVGA
  26. VIDEOFORMAT_CIF, // 352 x 288 : CIF
  27. VIDEOFORMAT_IOS_MEDIUM, // 480 x 360 : IOS_MEDIUM
  28. VIDEOFORMAT_VGA, // 640 x 480 : VGA
  29. VIDEOFORMAT_4CIF, // 704 x 576 : 4CIF
  30. VIDEOFORMAT_SVGA, // 800 x 600 : SVGA
  31. VIDEOFORMAT_XGA, // 1024 x 768 : XGA
  32. VIDEOFORMAT_SXGA, // 1280 x 1024 : SXGA
  33. VIDEOFORMAT_16CIF, // 1408 x 1152 : 16CIF
  34. } VIDEOFORMAT;
  35. // Macro to convert a video format to its size
  36. #define VIDEOFORMAT_TO_SIZE(format, width, height) \
  37. switch(format) \
  38. { \
  39. case VIDEOFORMAT_SQCIF: width = 128; height = 96; break; \
  40. case VIDEOFORMAT_QCIF: width = 176; height = 144; break; \
  41. case VIDEOFORMAT_QVGA: width = 320; height = 240; break; \
  42. case VIDEOFORMAT_CIF: width = 352; height = 288; break; \
  43. case VIDEOFORMAT_IOS_MEDIUM: width = 480; height = 360; break; \
  44. case VIDEOFORMAT_VGA: width = 640; height = 480; break; \
  45. case VIDEOFORMAT_4CIF: width = 704; height = 576; break; \
  46. case VIDEOFORMAT_SVGA: width = 800; height = 600; break; \
  47. case VIDEOFORMAT_XGA: width = 1024; height = 768; break; \
  48. case VIDEOFORMAT_SXGA: width = 1280; height = 1024; break; \
  49. case VIDEOFORMAT_16CIF: width = 1408; height = 1152; break; \
  50. case VIDEOFORMAT_NULL: \
  51. default: width = 0; height = 0; break; \
  52. } \
  53. // Macro to get a video format from its size
  54. #define SIZE_TO_VIDEOFORMAT(width, height, format) \
  55. if ((width == 128) && (height = 96)) format = VIDEOFORMAT_SQCIF; \
  56. else if ((width == 176) && (height = 144)) format = VIDEOFORMAT_QCIF; \
  57. else if ((width == 320) && (height = 240)) format = VIDEOFORMAT_QVGA; \
  58. else if ((width == 352) && (height = 288)) format = VIDEOFORMAT_CIF; \
  59. else if ((width == 480) && (height = 360)) format = VIDEOFORMAT_IOS_MEDIUM; \
  60. else if ((width == 640) && (height = 480)) format = VIDEOFORMAT_VGA; \
  61. else if ((width == 704) && (height = 576)) format = VIDEOFORMAT_4CIF; \
  62. else if ((width == 800) && (height = 600)) format = VIDEOFORMAT_SVGA; \
  63. else if ((width == 1024) && (height = 768)) format = VIDEOFORMAT_XGA; \
  64. else if ((width == 1280) && (height = 1024)) format = VIDEOFORMAT_SXGA; \
  65. else if ((width == 1408) && (height = 1152)) format = VIDEOFORMAT_16CIF; \
  66. else format = VIDEOFORMAT_NULL; \
  67. // Constants for consumer and producer Ids
  68. #define GRABBER_VIDEO_ID 0x1FFFFFFF
  69. #define REMOTE_VIDEO_ID 0x2FFFFFFF
  70. class VideoFrame
  71. {
  72. public:
  73. VideoFrame() {
  74. this->data = NULL;
  75. };
  76. virtual ~VideoFrame() {
  77. if(this->data) {
  78. this->data = NULL;
  79. }
  80. };
  81. int getWidth() {
  82. return this->width;
  83. };
  84. int getHeight() {
  85. return this->height;
  86. };
  87. int getBitsPerPixel() {
  88. return this->bpp;
  89. };
  90. int getTotalBits () {
  91. return this->width * this->height * (this->bpp/8);
  92. };
  93. void* getData() {
  94. return this->data;
  95. };
  96. void setWidth(int width_) {
  97. this->width = width_;
  98. };
  99. void setHeight(int height_) {
  100. this->height = height_;
  101. };
  102. void setBitsPerPixel( int bpp_) {
  103. this->bpp = bpp_;
  104. };
  105. void setData( void* data_) {
  106. this->data = data_;
  107. };
  108. VIDEOFORMAT getSize();
  109. void setSize(VIDEOFORMAT format);
  110. private:
  111. void *data;
  112. int width;
  113. int height;
  114. int bpp;
  115. };
  116. #endif /* VIDEOFRAME_H */