Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1169)

Side by Side Diff: talk/app/webrtc/androidvideocapturer.cc

Issue 1335923002: Add RTC_ prefix to (D)CHECKs and related macros. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | talk/app/webrtc/datachannelinterface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 const cricket::CapturedFrame* GetCapturedFrame() const { 76 const cricket::CapturedFrame* GetCapturedFrame() const {
77 return &captured_frame_; 77 return &captured_frame_;
78 } 78 }
79 79
80 cricket::VideoFrame* CreateAliasedFrame( 80 cricket::VideoFrame* CreateAliasedFrame(
81 const cricket::CapturedFrame* captured_frame, 81 const cricket::CapturedFrame* captured_frame,
82 int dst_width, 82 int dst_width,
83 int dst_height) const override { 83 int dst_height) const override {
84 // Check that captured_frame is actually our frame. 84 // Check that captured_frame is actually our frame.
85 CHECK(captured_frame == &captured_frame_); 85 RTC_CHECK(captured_frame == &captured_frame_);
86 rtc::scoped_ptr<cricket::VideoFrame> frame(new cricket::WebRtcVideoFrame( 86 rtc::scoped_ptr<cricket::VideoFrame> frame(new cricket::WebRtcVideoFrame(
87 ShallowCenterCrop(buffer_, dst_width, dst_height), 87 ShallowCenterCrop(buffer_, dst_width, dst_height),
88 captured_frame->elapsed_time, captured_frame->time_stamp, 88 captured_frame->elapsed_time, captured_frame->time_stamp,
89 captured_frame->GetRotation())); 89 captured_frame->GetRotation()));
90 // Caller takes ownership. 90 // Caller takes ownership.
91 // TODO(magjed): Change CreateAliasedFrame() to return a rtc::scoped_ptr. 91 // TODO(magjed): Change CreateAliasedFrame() to return a rtc::scoped_ptr.
92 return apply_rotation_ ? frame->GetCopyWithRotationApplied()->Copy() 92 return apply_rotation_ ? frame->GetCopyWithRotationApplied()->Copy()
93 : frame.release(); 93 : frame.release();
94 } 94 }
95 95
(...skipping 16 matching lines...) Expand all
112 112
113 Json::Value json_values; 113 Json::Value json_values;
114 Json::Reader reader(Json::Features::strictMode()); 114 Json::Reader reader(Json::Features::strictMode());
115 if (!reader.parse(json_string, json_values)) { 115 if (!reader.parse(json_string, json_values)) {
116 LOG(LS_ERROR) << "Failed to parse formats."; 116 LOG(LS_ERROR) << "Failed to parse formats.";
117 } 117 }
118 118
119 std::vector<cricket::VideoFormat> formats; 119 std::vector<cricket::VideoFormat> formats;
120 for (Json::ArrayIndex i = 0; i < json_values.size(); ++i) { 120 for (Json::ArrayIndex i = 0; i < json_values.size(); ++i) {
121 const Json::Value& json_value = json_values[i]; 121 const Json::Value& json_value = json_values[i];
122 CHECK(!json_value["width"].isNull() && !json_value["height"].isNull() && 122 RTC_CHECK(!json_value["width"].isNull() &&
123 !json_value["framerate"].isNull()); 123 !json_value["height"].isNull() &&
124 !json_value["framerate"].isNull());
124 cricket::VideoFormat format( 125 cricket::VideoFormat format(
125 json_value["width"].asInt(), 126 json_value["width"].asInt(),
126 json_value["height"].asInt(), 127 json_value["height"].asInt(),
127 cricket::VideoFormat::FpsToInterval(json_value["framerate"].asInt()), 128 cricket::VideoFormat::FpsToInterval(json_value["framerate"].asInt()),
128 cricket::FOURCC_YV12); 129 cricket::FOURCC_YV12);
129 formats.push_back(format); 130 formats.push_back(format);
130 } 131 }
131 SetSupportedFormats(formats); 132 SetSupportedFormats(formats);
132 // Do not apply frame rotation by default. 133 // Do not apply frame rotation by default.
133 SetApplyRotation(false); 134 SetApplyRotation(false);
134 } 135 }
135 136
136 AndroidVideoCapturer::~AndroidVideoCapturer() { 137 AndroidVideoCapturer::~AndroidVideoCapturer() {
137 CHECK(!running_); 138 RTC_CHECK(!running_);
138 } 139 }
139 140
140 cricket::CaptureState AndroidVideoCapturer::Start( 141 cricket::CaptureState AndroidVideoCapturer::Start(
141 const cricket::VideoFormat& capture_format) { 142 const cricket::VideoFormat& capture_format) {
142 CHECK(thread_checker_.CalledOnValidThread()); 143 RTC_CHECK(thread_checker_.CalledOnValidThread());
143 CHECK(!running_); 144 RTC_CHECK(!running_);
144 const int fps = cricket::VideoFormat::IntervalToFps(capture_format.interval); 145 const int fps = cricket::VideoFormat::IntervalToFps(capture_format.interval);
145 LOG(LS_INFO) << " AndroidVideoCapturer::Start " << capture_format.width << "x" 146 LOG(LS_INFO) << " AndroidVideoCapturer::Start " << capture_format.width << "x"
146 << capture_format.height << "@" << fps; 147 << capture_format.height << "@" << fps;
147 148
148 frame_factory_ = new AndroidVideoCapturer::FrameFactory(delegate_.get()); 149 frame_factory_ = new AndroidVideoCapturer::FrameFactory(delegate_.get());
149 set_frame_factory(frame_factory_); 150 set_frame_factory(frame_factory_);
150 151
151 running_ = true; 152 running_ = true;
152 delegate_->Start(capture_format.width, capture_format.height, fps, this); 153 delegate_->Start(capture_format.width, capture_format.height, fps, this);
153 SetCaptureFormat(&capture_format); 154 SetCaptureFormat(&capture_format);
154 current_state_ = cricket::CS_STARTING; 155 current_state_ = cricket::CS_STARTING;
155 return current_state_; 156 return current_state_;
156 } 157 }
157 158
158 void AndroidVideoCapturer::Stop() { 159 void AndroidVideoCapturer::Stop() {
159 LOG(LS_INFO) << " AndroidVideoCapturer::Stop "; 160 LOG(LS_INFO) << " AndroidVideoCapturer::Stop ";
160 CHECK(thread_checker_.CalledOnValidThread()); 161 RTC_CHECK(thread_checker_.CalledOnValidThread());
161 CHECK(running_); 162 RTC_CHECK(running_);
162 running_ = false; 163 running_ = false;
163 SetCaptureFormat(NULL); 164 SetCaptureFormat(NULL);
164 165
165 delegate_->Stop(); 166 delegate_->Stop();
166 current_state_ = cricket::CS_STOPPED; 167 current_state_ = cricket::CS_STOPPED;
167 SignalStateChange(this, current_state_); 168 SignalStateChange(this, current_state_);
168 } 169 }
169 170
170 bool AndroidVideoCapturer::IsRunning() { 171 bool AndroidVideoCapturer::IsRunning() {
171 CHECK(thread_checker_.CalledOnValidThread()); 172 RTC_CHECK(thread_checker_.CalledOnValidThread());
172 return running_; 173 return running_;
173 } 174 }
174 175
175 bool AndroidVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) { 176 bool AndroidVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) {
176 CHECK(thread_checker_.CalledOnValidThread()); 177 RTC_CHECK(thread_checker_.CalledOnValidThread());
177 fourccs->push_back(cricket::FOURCC_YV12); 178 fourccs->push_back(cricket::FOURCC_YV12);
178 return true; 179 return true;
179 } 180 }
180 181
181 void AndroidVideoCapturer::OnCapturerStarted(bool success) { 182 void AndroidVideoCapturer::OnCapturerStarted(bool success) {
182 CHECK(thread_checker_.CalledOnValidThread()); 183 RTC_CHECK(thread_checker_.CalledOnValidThread());
183 cricket::CaptureState new_state = 184 cricket::CaptureState new_state =
184 success ? cricket::CS_RUNNING : cricket::CS_FAILED; 185 success ? cricket::CS_RUNNING : cricket::CS_FAILED;
185 if (new_state == current_state_) 186 if (new_state == current_state_)
186 return; 187 return;
187 current_state_ = new_state; 188 current_state_ = new_state;
188 189
189 // TODO(perkj): SetCaptureState can not be used since it posts to |thread_|. 190 // TODO(perkj): SetCaptureState can not be used since it posts to |thread_|.
190 // But |thread_ | is currently just the thread that happened to create the 191 // But |thread_ | is currently just the thread that happened to create the
191 // cricket::VideoCapturer. 192 // cricket::VideoCapturer.
192 SignalStateChange(this, new_state); 193 SignalStateChange(this, new_state);
193 } 194 }
194 195
195 void AndroidVideoCapturer::OnIncomingFrame( 196 void AndroidVideoCapturer::OnIncomingFrame(
196 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer, 197 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer,
197 int rotation, 198 int rotation,
198 int64 time_stamp) { 199 int64 time_stamp) {
199 CHECK(thread_checker_.CalledOnValidThread()); 200 RTC_CHECK(thread_checker_.CalledOnValidThread());
200 frame_factory_->UpdateCapturedFrame(buffer, rotation, time_stamp); 201 frame_factory_->UpdateCapturedFrame(buffer, rotation, time_stamp);
201 SignalFrameCaptured(this, frame_factory_->GetCapturedFrame()); 202 SignalFrameCaptured(this, frame_factory_->GetCapturedFrame());
202 frame_factory_->ClearCapturedFrame(); 203 frame_factory_->ClearCapturedFrame();
203 } 204 }
204 205
205 void AndroidVideoCapturer::OnOutputFormatRequest( 206 void AndroidVideoCapturer::OnOutputFormatRequest(
206 int width, int height, int fps) { 207 int width, int height, int fps) {
207 CHECK(thread_checker_.CalledOnValidThread()); 208 RTC_CHECK(thread_checker_.CalledOnValidThread());
208 const cricket::VideoFormat& current = video_adapter()->output_format(); 209 const cricket::VideoFormat& current = video_adapter()->output_format();
209 cricket::VideoFormat format( 210 cricket::VideoFormat format(
210 width, height, cricket::VideoFormat::FpsToInterval(fps), current.fourcc); 211 width, height, cricket::VideoFormat::FpsToInterval(fps), current.fourcc);
211 video_adapter()->OnOutputFormatRequest(format); 212 video_adapter()->OnOutputFormatRequest(format);
212 } 213 }
213 214
214 bool AndroidVideoCapturer::GetBestCaptureFormat( 215 bool AndroidVideoCapturer::GetBestCaptureFormat(
215 const cricket::VideoFormat& desired, 216 const cricket::VideoFormat& desired,
216 cricket::VideoFormat* best_format) { 217 cricket::VideoFormat* best_format) {
217 // Delegate this choice to VideoCapturerAndroid.startCapture(). 218 // Delegate this choice to VideoCapturerAndroid.startCapture().
218 *best_format = desired; 219 *best_format = desired;
219 return true; 220 return true;
220 } 221 }
221 222
222 } // namespace webrtc 223 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | talk/app/webrtc/datachannelinterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698