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.time_stamp = initial_unix_timestamp_ + next_timestamp_; | 117 frame.time_stamp = initial_unix_timestamp_ + next_timestamp_; |
118 next_timestamp_ += timestamp_interval; | 118 next_timestamp_ += timestamp_interval; |
119 | 119 |
120 rtc::scoped_ptr<char[]> data(new char[size]); | 120 rtc::scoped_ptr<char[]> data(new char[size]); |
121 frame.data = data.get(); | 121 frame.data = data.get(); |
122 // Copy something non-zero into the buffer so Validate wont complain that | 122 // Copy something non-zero into the buffer so Validate wont complain that |
123 // the frame is all duplicate. | 123 // the frame is all duplicate. |
124 memset(frame.data, 1, size / 2); | 124 memset(frame.data, 1, size / 2); |
125 memset(reinterpret_cast<uint8*>(frame.data) + (size / 2), 2, | 125 memset(reinterpret_cast<uint8_t*>(frame.data) + (size / 2), 2, |
126 size - (size / 2)); | 126 size - (size / 2)); |
127 memcpy(frame.data, reinterpret_cast<const uint8*>(&fourcc), 4); | 127 memcpy(frame.data, reinterpret_cast<const uint8_t*>(&fourcc), 4); |
128 frame.rotation = rotation_; | 128 frame.rotation = rotation_; |
129 // TODO(zhurunz): SignalFrameCaptured carry returned value to be able to | 129 // TODO(zhurunz): SignalFrameCaptured carry returned value to be able to |
130 // capture results from downstream. | 130 // capture results from downstream. |
131 SignalFrameCaptured(this, &frame); | 131 SignalFrameCaptured(this, &frame); |
132 return true; | 132 return true; |
133 } | 133 } |
134 | 134 |
135 void SignalCapturedFrame(cricket::CapturedFrame* frame) { | 135 void SignalCapturedFrame(cricket::CapturedFrame* frame) { |
136 SignalFrameCaptured(this, frame); | 136 SignalFrameCaptured(this, frame); |
137 } | 137 } |
(...skipping 12 matching lines...) Expand all Loading... |
150 virtual void Stop() { | 150 virtual void Stop() { |
151 running_ = false; | 151 running_ = false; |
152 SetCaptureFormat(NULL); | 152 SetCaptureFormat(NULL); |
153 SetCaptureState(cricket::CS_STOPPED); | 153 SetCaptureState(cricket::CS_STOPPED); |
154 } | 154 } |
155 virtual bool IsRunning() { return running_; } | 155 virtual bool IsRunning() { return running_; } |
156 void SetScreencast(bool is_screencast) { | 156 void SetScreencast(bool is_screencast) { |
157 is_screencast_ = is_screencast; | 157 is_screencast_ = is_screencast; |
158 } | 158 } |
159 virtual bool IsScreencast() const { return is_screencast_; } | 159 virtual bool IsScreencast() const { return is_screencast_; } |
160 bool GetPreferredFourccs(std::vector<uint32>* fourccs) { | 160 bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) { |
161 fourccs->push_back(cricket::FOURCC_I420); | 161 fourccs->push_back(cricket::FOURCC_I420); |
162 fourccs->push_back(cricket::FOURCC_MJPG); | 162 fourccs->push_back(cricket::FOURCC_MJPG); |
163 return true; | 163 return true; |
164 } | 164 } |
165 | 165 |
166 void SetRotation(webrtc::VideoRotation rotation) { | 166 void SetRotation(webrtc::VideoRotation rotation) { |
167 rotation_ = rotation; | 167 rotation_ = rotation; |
168 } | 168 } |
169 | 169 |
170 webrtc::VideoRotation GetRotation() { return rotation_; } | 170 webrtc::VideoRotation GetRotation() { return rotation_; } |
171 | 171 |
172 private: | 172 private: |
173 bool running_; | 173 bool running_; |
174 int64 initial_unix_timestamp_; | 174 int64_t initial_unix_timestamp_; |
175 int64 next_timestamp_; | 175 int64_t next_timestamp_; |
176 bool is_screencast_; | 176 bool is_screencast_; |
177 webrtc::VideoRotation rotation_; | 177 webrtc::VideoRotation rotation_; |
178 }; | 178 }; |
179 | 179 |
180 } // namespace cricket | 180 } // namespace cricket |
181 | 181 |
182 #endif // TALK_MEDIA_BASE_FAKEVIDEOCAPTURER_H_ | 182 #endif // TALK_MEDIA_BASE_FAKEVIDEOCAPTURER_H_ |
OLD | NEW |