OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 #include "webrtc/base/basictypes.h" | 42 #include "webrtc/base/basictypes.h" |
43 #include "webrtc/base/constructormagic.h" | 43 #include "webrtc/base/constructormagic.h" |
44 | 44 |
45 namespace cricket { | 45 namespace cricket { |
46 | 46 |
47 class YuvFrameGenerator { | 47 class YuvFrameGenerator { |
48 public: | 48 public: |
49 // Constructs a frame-generator that produces frames of size |width|x|height|. | 49 // Constructs a frame-generator that produces frames of size |width|x|height|. |
50 // If |enable_barcode| is specified, barcodes can be included in the frames | 50 // If |enable_barcode| is specified, barcodes can be included in the frames |
51 // when calling |GenerateNextFrame(uint8*, uint32)|. If |enable_barcode| is | 51 // when calling |GenerateNextFrame(uint8_t*, uint32_t)|. If |enable_barcode| |
52 // |true| then |width|x|height| should be at least 160x100; otherwise this | 52 // is |true| then |width|x|height| should be at least 160x100; otherwise this |
53 // constructor will abort. | 53 // constructor will abort. |
54 YuvFrameGenerator(int width, int height, bool enable_barcode); | 54 YuvFrameGenerator(int width, int height, bool enable_barcode); |
55 ~YuvFrameGenerator(); | 55 ~YuvFrameGenerator(); |
56 | 56 |
57 int GetFrameSize() { return frame_data_size_; } | 57 int GetFrameSize() { return frame_data_size_; } |
58 | 58 |
59 // Generate the next frame and return it in the provided |frame_buffer|. If | 59 // Generate the next frame and return it in the provided |frame_buffer|. If |
60 // barcode_value is not |nullptr| the value referred by it will be encoded | 60 // barcode_value is not |nullptr| the value referred by it will be encoded |
61 // into a barcode in the frame. The value should in the range: | 61 // into a barcode in the frame. The value should in the range: |
62 // [0..9,999,999]. If the value exceeds this range or barcodes were not | 62 // [0..9,999,999]. If the value exceeds this range or barcodes were not |
63 // requested in the constructor, this function will abort. | 63 // requested in the constructor, this function will abort. |
64 void GenerateNextFrame(uint8* frame_buffer, int32 barcode_value); | 64 void GenerateNextFrame(uint8_t* frame_buffer, int32_t barcode_value); |
65 | 65 |
66 int GetHeight() { return height_; } | 66 int GetHeight() { return height_; } |
67 int GetWidth() { return width_; } | 67 int GetWidth() { return width_; } |
68 | 68 |
69 // Fetch the bounds of the barcode from the generator. The barcode will | 69 // Fetch the bounds of the barcode from the generator. The barcode will |
70 // always be at this location. This function will abort if barcodes were not | 70 // always be at this location. This function will abort if barcodes were not |
71 // requested in the constructor. | 71 // requested in the constructor. |
72 void GetBarcodeBounds(int* top, int* left, int* width, int* height); | 72 void GetBarcodeBounds(int* top, int* left, int* width, int* height); |
73 | 73 |
74 private: | 74 private: |
75 void DrawLandscape(uint8 *p, int w, int h); | 75 void DrawLandscape(uint8_t* p, int w, int h); |
76 void DrawGradientX(uint8 *p, int w, int h); | 76 void DrawGradientX(uint8_t* p, int w, int h); |
77 void DrawGradientY(uint8 *p, int w, int h); | 77 void DrawGradientY(uint8_t* p, int w, int h); |
78 void DrawMovingLineX(uint8 *p, int w, int h, int n); | 78 void DrawMovingLineX(uint8_t* p, int w, int h, int n); |
79 void DrawMovingLineY(uint8 *p, int w, int h, int n); | 79 void DrawMovingLineY(uint8_t* p, int w, int h, int n); |
80 void DrawBouncingCube(uint8 *p, int w, int h, int n); | 80 void DrawBouncingCube(uint8_t* p, int w, int h, int n); |
81 | 81 |
82 void DrawBarcode(uint32 value); | 82 void DrawBarcode(uint32_t value); |
83 int DrawSideGuardBars(int x, int y, int height); | 83 int DrawSideGuardBars(int x, int y, int height); |
84 int DrawMiddleGuardBars(int x, int y, int height); | 84 int DrawMiddleGuardBars(int x, int y, int height); |
85 int DrawEanEncodedDigit(int digit, int x, int y, int height, bool r_code); | 85 int DrawEanEncodedDigit(int digit, int x, int y, int height, bool r_code); |
86 void DrawBlockRectangle(uint8* p, int x_start, int y_start, | 86 void DrawBlockRectangle(uint8_t* p, |
87 int width, int height, int pitch, uint8 value); | 87 int x_start, |
| 88 int y_start, |
| 89 int width, |
| 90 int height, |
| 91 int pitch, |
| 92 uint8_t value); |
88 | 93 |
89 private: | 94 private: |
90 int width_; | 95 int width_; |
91 int height_; | 96 int height_; |
92 int frame_index_; | 97 int frame_index_; |
93 int frame_data_size_; | 98 int frame_data_size_; |
94 uint8* y_data_; | 99 uint8_t* y_data_; |
95 uint8* u_data_; | 100 uint8_t* u_data_; |
96 uint8* v_data_; | 101 uint8_t* v_data_; |
97 | 102 |
98 int barcode_start_x_; | 103 int barcode_start_x_; |
99 int barcode_start_y_; | 104 int barcode_start_y_; |
100 | 105 |
101 RTC_DISALLOW_COPY_AND_ASSIGN(YuvFrameGenerator); | 106 RTC_DISALLOW_COPY_AND_ASSIGN(YuvFrameGenerator); |
102 }; | 107 }; |
103 | 108 |
104 } // namespace cricket | 109 } // namespace cricket |
105 | 110 |
106 #endif // TALK_MEDIA_BASE_YUVFRAMEGENERATOR_H_ | 111 #endif // TALK_MEDIA_BASE_YUVFRAMEGENERATOR_H_ |
OLD | NEW |