OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 bool CaptureFrame() { | 78 bool CaptureFrame() { |
79 if (!GetCaptureFormat()) { | 79 if (!GetCaptureFormat()) { |
80 return false; | 80 return false; |
81 } | 81 } |
82 return CaptureCustomFrame(GetCaptureFormat()->width, | 82 return CaptureCustomFrame(GetCaptureFormat()->width, |
83 GetCaptureFormat()->height, | 83 GetCaptureFormat()->height, |
84 GetCaptureFormat()->interval, | 84 GetCaptureFormat()->interval, |
85 GetCaptureFormat()->fourcc); | 85 GetCaptureFormat()->fourcc); |
86 } | 86 } |
87 bool CaptureCustomFrame(int width, int height, uint32 fourcc) { | 87 bool CaptureCustomFrame(int width, int height, uint32_t fourcc) { |
88 // default to 30fps | 88 // default to 30fps |
89 return CaptureCustomFrame(width, height, 33333333, fourcc); | 89 return CaptureCustomFrame(width, height, 33333333, fourcc); |
90 } | 90 } |
91 bool CaptureCustomFrame(int width, | 91 bool CaptureCustomFrame(int width, |
92 int height, | 92 int height, |
93 int64_t timestamp_interval, | 93 int64_t timestamp_interval, |
94 uint32 fourcc) { | 94 uint32_t fourcc) { |
95 if (!running_) { | 95 if (!running_) { |
96 return false; | 96 return false; |
97 } | 97 } |
98 // Currently, |fourcc| is always I420 or ARGB. | 98 // Currently, |fourcc| is always I420 or ARGB. |
99 // TODO(fbarchard): Extend SizeOf to take fourcc. | 99 // TODO(fbarchard): Extend SizeOf to take fourcc. |
100 uint32 size = 0u; | 100 uint32_t size = 0u; |
101 if (fourcc == cricket::FOURCC_ARGB) { | 101 if (fourcc == cricket::FOURCC_ARGB) { |
102 size = width * 4 * height; | 102 size = width * 4 * height; |
103 } else if (fourcc == cricket::FOURCC_I420) { | 103 } else if (fourcc == cricket::FOURCC_I420) { |
104 size = static_cast<uint32>(cricket::VideoFrame::SizeOf(width, height)); | 104 size = static_cast<uint32_t>(cricket::VideoFrame::SizeOf(width, height)); |
105 } else { | 105 } else { |
106 return false; // Unsupported FOURCC. | 106 return false; // Unsupported FOURCC. |
107 } | 107 } |
108 if (size == 0u) { | 108 if (size == 0u) { |
109 return false; // Width and/or Height were zero. | 109 return false; // Width and/or Height were zero. |
110 } | 110 } |
111 | 111 |
112 cricket::CapturedFrame frame; | 112 cricket::CapturedFrame frame; |
113 frame.width = width; | 113 frame.width = width; |
114 frame.height = height; | 114 frame.height = height; |
115 frame.fourcc = fourcc; | 115 frame.fourcc = fourcc; |
116 frame.data_size = size; | 116 frame.data_size = size; |
117 frame.elapsed_time = next_timestamp_; | 117 frame.elapsed_time = next_timestamp_; |
118 frame.time_stamp = initial_unix_timestamp_ + next_timestamp_; | 118 frame.time_stamp = initial_unix_timestamp_ + next_timestamp_; |
119 next_timestamp_ += timestamp_interval; | 119 next_timestamp_ += timestamp_interval; |
120 | 120 |
121 rtc::scoped_ptr<char[]> data(new char[size]); | 121 rtc::scoped_ptr<char[]> data(new char[size]); |
122 frame.data = data.get(); | 122 frame.data = data.get(); |
123 // Copy something non-zero into the buffer so Validate wont complain that | 123 // Copy something non-zero into the buffer so Validate wont complain that |
124 // the frame is all duplicate. | 124 // the frame is all duplicate. |
125 memset(frame.data, 1, size / 2); | 125 memset(frame.data, 1, size / 2); |
126 memset(reinterpret_cast<uint8*>(frame.data) + (size / 2), 2, | 126 memset(reinterpret_cast<uint8_t*>(frame.data) + (size / 2), 2, |
127 size - (size / 2)); | 127 size - (size / 2)); |
128 memcpy(frame.data, reinterpret_cast<const uint8*>(&fourcc), 4); | 128 memcpy(frame.data, reinterpret_cast<const uint8_t*>(&fourcc), 4); |
129 frame.rotation = rotation_; | 129 frame.rotation = rotation_; |
130 // TODO(zhurunz): SignalFrameCaptured carry returned value to be able to | 130 // TODO(zhurunz): SignalFrameCaptured carry returned value to be able to |
131 // capture results from downstream. | 131 // capture results from downstream. |
132 SignalFrameCaptured(this, &frame); | 132 SignalFrameCaptured(this, &frame); |
133 return true; | 133 return true; |
134 } | 134 } |
135 | 135 |
136 void SignalCapturedFrame(cricket::CapturedFrame* frame) { | 136 void SignalCapturedFrame(cricket::CapturedFrame* frame) { |
137 SignalFrameCaptured(this, frame); | 137 SignalFrameCaptured(this, frame); |
138 } | 138 } |
(...skipping 12 matching lines...) Expand all Loading... |
151 virtual void Stop() { | 151 virtual void Stop() { |
152 running_ = false; | 152 running_ = false; |
153 SetCaptureFormat(NULL); | 153 SetCaptureFormat(NULL); |
154 SetCaptureState(cricket::CS_STOPPED); | 154 SetCaptureState(cricket::CS_STOPPED); |
155 } | 155 } |
156 virtual bool IsRunning() { return running_; } | 156 virtual bool IsRunning() { return running_; } |
157 void SetScreencast(bool is_screencast) { | 157 void SetScreencast(bool is_screencast) { |
158 is_screencast_ = is_screencast; | 158 is_screencast_ = is_screencast; |
159 } | 159 } |
160 virtual bool IsScreencast() const { return is_screencast_; } | 160 virtual bool IsScreencast() const { return is_screencast_; } |
161 bool GetPreferredFourccs(std::vector<uint32>* fourccs) { | 161 bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) { |
162 fourccs->push_back(cricket::FOURCC_I420); | 162 fourccs->push_back(cricket::FOURCC_I420); |
163 fourccs->push_back(cricket::FOURCC_MJPG); | 163 fourccs->push_back(cricket::FOURCC_MJPG); |
164 return true; | 164 return true; |
165 } | 165 } |
166 | 166 |
167 void SetRotation(webrtc::VideoRotation rotation) { | 167 void SetRotation(webrtc::VideoRotation rotation) { |
168 rotation_ = rotation; | 168 rotation_ = rotation; |
169 } | 169 } |
170 | 170 |
171 webrtc::VideoRotation GetRotation() { return rotation_; } | 171 webrtc::VideoRotation GetRotation() { return rotation_; } |
172 | 172 |
173 private: | 173 private: |
174 bool running_; | 174 bool running_; |
175 int64 initial_unix_timestamp_; | 175 int64_t initial_unix_timestamp_; |
176 int64 next_timestamp_; | 176 int64_t next_timestamp_; |
177 bool is_screencast_; | 177 bool is_screencast_; |
178 webrtc::VideoRotation rotation_; | 178 webrtc::VideoRotation rotation_; |
179 }; | 179 }; |
180 | 180 |
181 } // namespace cricket | 181 } // namespace cricket |
182 | 182 |
183 #endif // TALK_MEDIA_BASE_FAKEVIDEOCAPTURER_H_ | 183 #endif // TALK_MEDIA_BASE_FAKEVIDEOCAPTURER_H_ |
OLD | NEW |