| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 static VideoCapturerState* Create(VideoCapturer* video_capturer); | 44 static VideoCapturerState* Create(VideoCapturer* video_capturer); |
| 45 ~VideoCapturerState() {} | 45 ~VideoCapturerState() {} |
| 46 | 46 |
| 47 void AddCaptureResolution(const VideoFormat& desired_format); | 47 void AddCaptureResolution(const VideoFormat& desired_format); |
| 48 bool RemoveCaptureResolution(const VideoFormat& format); | 48 bool RemoveCaptureResolution(const VideoFormat& format); |
| 49 VideoFormat GetHighestFormat(VideoCapturer* video_capturer) const; | 49 VideoFormat GetHighestFormat(VideoCapturer* video_capturer) const; |
| 50 | 50 |
| 51 int IncCaptureStartRef(); | 51 int IncCaptureStartRef(); |
| 52 int DecCaptureStartRef(); | 52 int DecCaptureStartRef(); |
| 53 CaptureRenderAdapter* adapter() { | 53 CaptureRenderAdapter* adapter() { |
| 54 DCHECK(thread_checker_.CalledOnValidThread()); | 54 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 55 return adapter_.get(); | 55 return adapter_.get(); |
| 56 } | 56 } |
| 57 VideoCapturer* GetVideoCapturer() { | 57 VideoCapturer* GetVideoCapturer() { |
| 58 DCHECK(thread_checker_.CalledOnValidThread()); | 58 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 59 return adapter()->video_capturer(); | 59 return adapter()->video_capturer(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 int start_count() const { | 62 int start_count() const { |
| 63 DCHECK(thread_checker_.CalledOnValidThread()); | 63 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 64 return start_count_; | 64 return start_count_; |
| 65 } | 65 } |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 struct CaptureResolutionInfo { | 68 struct CaptureResolutionInfo { |
| 69 VideoFormat video_format; | 69 VideoFormat video_format; |
| 70 int format_ref_count; | 70 int format_ref_count; |
| 71 }; | 71 }; |
| 72 typedef std::vector<CaptureResolutionInfo> CaptureFormats; | 72 typedef std::vector<CaptureResolutionInfo> CaptureFormats; |
| 73 | 73 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 91 VideoCapturerState* VideoCapturerState::Create(VideoCapturer* video_capturer) { | 91 VideoCapturerState* VideoCapturerState::Create(VideoCapturer* video_capturer) { |
| 92 CaptureRenderAdapter* adapter = CaptureRenderAdapter::Create(video_capturer); | 92 CaptureRenderAdapter* adapter = CaptureRenderAdapter::Create(video_capturer); |
| 93 if (!adapter) { | 93 if (!adapter) { |
| 94 return NULL; | 94 return NULL; |
| 95 } | 95 } |
| 96 return new VideoCapturerState(adapter); | 96 return new VideoCapturerState(adapter); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void VideoCapturerState::AddCaptureResolution( | 99 void VideoCapturerState::AddCaptureResolution( |
| 100 const VideoFormat& desired_format) { | 100 const VideoFormat& desired_format) { |
| 101 DCHECK(thread_checker_.CalledOnValidThread()); | 101 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 102 for (CaptureFormats::iterator iter = capture_formats_.begin(); | 102 for (CaptureFormats::iterator iter = capture_formats_.begin(); |
| 103 iter != capture_formats_.end(); ++iter) { | 103 iter != capture_formats_.end(); ++iter) { |
| 104 if (desired_format == iter->video_format) { | 104 if (desired_format == iter->video_format) { |
| 105 ++(iter->format_ref_count); | 105 ++(iter->format_ref_count); |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 CaptureResolutionInfo capture_resolution = { desired_format, 1 }; | 109 CaptureResolutionInfo capture_resolution = { desired_format, 1 }; |
| 110 capture_formats_.push_back(capture_resolution); | 110 capture_formats_.push_back(capture_resolution); |
| 111 } | 111 } |
| 112 | 112 |
| 113 bool VideoCapturerState::RemoveCaptureResolution(const VideoFormat& format) { | 113 bool VideoCapturerState::RemoveCaptureResolution(const VideoFormat& format) { |
| 114 DCHECK(thread_checker_.CalledOnValidThread()); | 114 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 115 for (CaptureFormats::iterator iter = capture_formats_.begin(); | 115 for (CaptureFormats::iterator iter = capture_formats_.begin(); |
| 116 iter != capture_formats_.end(); ++iter) { | 116 iter != capture_formats_.end(); ++iter) { |
| 117 if (format == iter->video_format) { | 117 if (format == iter->video_format) { |
| 118 --(iter->format_ref_count); | 118 --(iter->format_ref_count); |
| 119 if (iter->format_ref_count == 0) { | 119 if (iter->format_ref_count == 0) { |
| 120 capture_formats_.erase(iter); | 120 capture_formats_.erase(iter); |
| 121 } | 121 } |
| 122 return true; | 122 return true; |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 return false; | 125 return false; |
| 126 } | 126 } |
| 127 | 127 |
| 128 VideoFormat VideoCapturerState::GetHighestFormat( | 128 VideoFormat VideoCapturerState::GetHighestFormat( |
| 129 VideoCapturer* video_capturer) const { | 129 VideoCapturer* video_capturer) const { |
| 130 DCHECK(thread_checker_.CalledOnValidThread()); | 130 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 131 VideoFormat highest_format(0, 0, VideoFormat::FpsToInterval(1), FOURCC_ANY); | 131 VideoFormat highest_format(0, 0, VideoFormat::FpsToInterval(1), FOURCC_ANY); |
| 132 if (capture_formats_.empty()) { | 132 if (capture_formats_.empty()) { |
| 133 VideoFormat default_format(kDefaultCaptureFormat); | 133 VideoFormat default_format(kDefaultCaptureFormat); |
| 134 return default_format; | 134 return default_format; |
| 135 } | 135 } |
| 136 for (CaptureFormats::const_iterator iter = capture_formats_.begin(); | 136 for (CaptureFormats::const_iterator iter = capture_formats_.begin(); |
| 137 iter != capture_formats_.end(); ++iter) { | 137 iter != capture_formats_.end(); ++iter) { |
| 138 if (iter->video_format.width > highest_format.width) { | 138 if (iter->video_format.width > highest_format.width) { |
| 139 highest_format.width = iter->video_format.width; | 139 highest_format.width = iter->video_format.width; |
| 140 } | 140 } |
| 141 if (iter->video_format.height > highest_format.height) { | 141 if (iter->video_format.height > highest_format.height) { |
| 142 highest_format.height = iter->video_format.height; | 142 highest_format.height = iter->video_format.height; |
| 143 } | 143 } |
| 144 if (iter->video_format.interval < highest_format.interval) { | 144 if (iter->video_format.interval < highest_format.interval) { |
| 145 highest_format.interval = iter->video_format.interval; | 145 highest_format.interval = iter->video_format.interval; |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 return highest_format; | 148 return highest_format; |
| 149 } | 149 } |
| 150 | 150 |
| 151 int VideoCapturerState::IncCaptureStartRef() { | 151 int VideoCapturerState::IncCaptureStartRef() { |
| 152 DCHECK(thread_checker_.CalledOnValidThread()); | 152 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 153 return ++start_count_; | 153 return ++start_count_; |
| 154 } | 154 } |
| 155 | 155 |
| 156 int VideoCapturerState::DecCaptureStartRef() { | 156 int VideoCapturerState::DecCaptureStartRef() { |
| 157 DCHECK(thread_checker_.CalledOnValidThread()); | 157 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 158 if (start_count_ > 0) { | 158 if (start_count_ > 0) { |
| 159 // Start count may be 0 if a capturer was added but never started. | 159 // Start count may be 0 if a capturer was added but never started. |
| 160 --start_count_; | 160 --start_count_; |
| 161 } | 161 } |
| 162 return start_count_; | 162 return start_count_; |
| 163 } | 163 } |
| 164 | 164 |
| 165 CaptureManager::CaptureManager() { | 165 CaptureManager::CaptureManager() { |
| 166 // Allowing construction of manager in any thread as long as subsequent calls | 166 // Allowing construction of manager in any thread as long as subsequent calls |
| 167 // are all from the same thread. | 167 // are all from the same thread. |
| 168 thread_checker_.DetachFromThread(); | 168 thread_checker_.DetachFromThread(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 CaptureManager::~CaptureManager() { | 171 CaptureManager::~CaptureManager() { |
| 172 DCHECK(thread_checker_.CalledOnValidThread()); | 172 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 173 | 173 |
| 174 // Since we don't own any of the capturers, all capturers should have been | 174 // Since we don't own any of the capturers, all capturers should have been |
| 175 // cleaned up before we get here. In fact, in the normal shutdown sequence, | 175 // cleaned up before we get here. In fact, in the normal shutdown sequence, |
| 176 // all capturers *will* be shut down by now, so trying to stop them here | 176 // all capturers *will* be shut down by now, so trying to stop them here |
| 177 // will crash. If we're still tracking any, it's a dangling pointer. | 177 // will crash. If we're still tracking any, it's a dangling pointer. |
| 178 // TODO(hbos): DCHECK instead of CHECK until we figure out why capture_states_ | 178 // TODO(hbos): RTC_DCHECK instead of RTC_CHECK until we figure out why |
| 179 // is not always empty here. | 179 // capture_states_ is not always empty here. |
| 180 DCHECK(capture_states_.empty()); | 180 RTC_DCHECK(capture_states_.empty()); |
| 181 } | 181 } |
| 182 | 182 |
| 183 bool CaptureManager::StartVideoCapture(VideoCapturer* video_capturer, | 183 bool CaptureManager::StartVideoCapture(VideoCapturer* video_capturer, |
| 184 const VideoFormat& desired_format) { | 184 const VideoFormat& desired_format) { |
| 185 DCHECK(thread_checker_.CalledOnValidThread()); | 185 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 186 if (desired_format.width == 0 || desired_format.height == 0) { | 186 if (desired_format.width == 0 || desired_format.height == 0) { |
| 187 return false; | 187 return false; |
| 188 } | 188 } |
| 189 if (!video_capturer) { | 189 if (!video_capturer) { |
| 190 return false; | 190 return false; |
| 191 } | 191 } |
| 192 VideoCapturerState* capture_state = GetCaptureState(video_capturer); | 192 VideoCapturerState* capture_state = GetCaptureState(video_capturer); |
| 193 if (capture_state) { | 193 if (capture_state) { |
| 194 const int ref_count = capture_state->IncCaptureStartRef(); | 194 const int ref_count = capture_state->IncCaptureStartRef(); |
| 195 if (ref_count < 1) { | 195 if (ref_count < 1) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 208 capture_state->AddCaptureResolution(desired_format); | 208 capture_state->AddCaptureResolution(desired_format); |
| 209 if (!StartWithBestCaptureFormat(capture_state, video_capturer)) { | 209 if (!StartWithBestCaptureFormat(capture_state, video_capturer)) { |
| 210 UnregisterVideoCapturer(capture_state); | 210 UnregisterVideoCapturer(capture_state); |
| 211 return false; | 211 return false; |
| 212 } | 212 } |
| 213 return true; | 213 return true; |
| 214 } | 214 } |
| 215 | 215 |
| 216 bool CaptureManager::StopVideoCapture(VideoCapturer* video_capturer, | 216 bool CaptureManager::StopVideoCapture(VideoCapturer* video_capturer, |
| 217 const VideoFormat& format) { | 217 const VideoFormat& format) { |
| 218 DCHECK(thread_checker_.CalledOnValidThread()); | 218 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 219 VideoCapturerState* capture_state = GetCaptureState(video_capturer); | 219 VideoCapturerState* capture_state = GetCaptureState(video_capturer); |
| 220 if (!capture_state) { | 220 if (!capture_state) { |
| 221 return false; | 221 return false; |
| 222 } | 222 } |
| 223 if (!capture_state->RemoveCaptureResolution(format)) { | 223 if (!capture_state->RemoveCaptureResolution(format)) { |
| 224 return false; | 224 return false; |
| 225 } | 225 } |
| 226 | 226 |
| 227 if (capture_state->DecCaptureStartRef() == 0) { | 227 if (capture_state->DecCaptureStartRef() == 0) { |
| 228 // Unregistering cannot fail as capture_state is not NULL. | 228 // Unregistering cannot fail as capture_state is not NULL. |
| 229 UnregisterVideoCapturer(capture_state); | 229 UnregisterVideoCapturer(capture_state); |
| 230 } | 230 } |
| 231 return true; | 231 return true; |
| 232 } | 232 } |
| 233 | 233 |
| 234 bool CaptureManager::RestartVideoCapture( | 234 bool CaptureManager::RestartVideoCapture( |
| 235 VideoCapturer* video_capturer, | 235 VideoCapturer* video_capturer, |
| 236 const VideoFormat& previous_format, | 236 const VideoFormat& previous_format, |
| 237 const VideoFormat& desired_format, | 237 const VideoFormat& desired_format, |
| 238 CaptureManager::RestartOptions options) { | 238 CaptureManager::RestartOptions options) { |
| 239 DCHECK(thread_checker_.CalledOnValidThread()); | 239 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 240 if (!IsCapturerRegistered(video_capturer)) { | 240 if (!IsCapturerRegistered(video_capturer)) { |
| 241 LOG(LS_ERROR) << "RestartVideoCapture: video_capturer is not registered."; | 241 LOG(LS_ERROR) << "RestartVideoCapture: video_capturer is not registered."; |
| 242 return false; | 242 return false; |
| 243 } | 243 } |
| 244 // Start the new format first. This keeps the capturer running. | 244 // Start the new format first. This keeps the capturer running. |
| 245 if (!StartVideoCapture(video_capturer, desired_format)) { | 245 if (!StartVideoCapture(video_capturer, desired_format)) { |
| 246 LOG(LS_ERROR) << "RestartVideoCapture: unable to start video capture with " | 246 LOG(LS_ERROR) << "RestartVideoCapture: unable to start video capture with " |
| 247 "desired_format=" << desired_format.ToString(); | 247 "desired_format=" << desired_format.ToString(); |
| 248 return false; | 248 return false; |
| 249 } | 249 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 break; | 282 break; |
| 283 default: | 283 default: |
| 284 LOG(LS_ERROR) << "Unknown/unimplemented RestartOption"; | 284 LOG(LS_ERROR) << "Unknown/unimplemented RestartOption"; |
| 285 break; | 285 break; |
| 286 } | 286 } |
| 287 return true; | 287 return true; |
| 288 } | 288 } |
| 289 | 289 |
| 290 bool CaptureManager::AddVideoRenderer(VideoCapturer* video_capturer, | 290 bool CaptureManager::AddVideoRenderer(VideoCapturer* video_capturer, |
| 291 VideoRenderer* video_renderer) { | 291 VideoRenderer* video_renderer) { |
| 292 DCHECK(thread_checker_.CalledOnValidThread()); | 292 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 293 if (!video_capturer || !video_renderer) { | 293 if (!video_capturer || !video_renderer) { |
| 294 return false; | 294 return false; |
| 295 } | 295 } |
| 296 CaptureRenderAdapter* adapter = GetAdapter(video_capturer); | 296 CaptureRenderAdapter* adapter = GetAdapter(video_capturer); |
| 297 if (!adapter) { | 297 if (!adapter) { |
| 298 return false; | 298 return false; |
| 299 } | 299 } |
| 300 return adapter->AddRenderer(video_renderer); | 300 return adapter->AddRenderer(video_renderer); |
| 301 } | 301 } |
| 302 | 302 |
| 303 bool CaptureManager::RemoveVideoRenderer(VideoCapturer* video_capturer, | 303 bool CaptureManager::RemoveVideoRenderer(VideoCapturer* video_capturer, |
| 304 VideoRenderer* video_renderer) { | 304 VideoRenderer* video_renderer) { |
| 305 DCHECK(thread_checker_.CalledOnValidThread()); | 305 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 306 if (!video_capturer || !video_renderer) { | 306 if (!video_capturer || !video_renderer) { |
| 307 return false; | 307 return false; |
| 308 } | 308 } |
| 309 CaptureRenderAdapter* adapter = GetAdapter(video_capturer); | 309 CaptureRenderAdapter* adapter = GetAdapter(video_capturer); |
| 310 if (!adapter) { | 310 if (!adapter) { |
| 311 return false; | 311 return false; |
| 312 } | 312 } |
| 313 return adapter->RemoveRenderer(video_renderer); | 313 return adapter->RemoveRenderer(video_renderer); |
| 314 } | 314 } |
| 315 | 315 |
| 316 bool CaptureManager::IsCapturerRegistered(VideoCapturer* video_capturer) const { | 316 bool CaptureManager::IsCapturerRegistered(VideoCapturer* video_capturer) const { |
| 317 DCHECK(thread_checker_.CalledOnValidThread()); | 317 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 318 return GetCaptureState(video_capturer) != NULL; | 318 return GetCaptureState(video_capturer) != NULL; |
| 319 } | 319 } |
| 320 | 320 |
| 321 bool CaptureManager::RegisterVideoCapturer(VideoCapturer* video_capturer) { | 321 bool CaptureManager::RegisterVideoCapturer(VideoCapturer* video_capturer) { |
| 322 DCHECK(thread_checker_.CalledOnValidThread()); | 322 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 323 VideoCapturerState* capture_state = | 323 VideoCapturerState* capture_state = |
| 324 VideoCapturerState::Create(video_capturer); | 324 VideoCapturerState::Create(video_capturer); |
| 325 if (!capture_state) { | 325 if (!capture_state) { |
| 326 return false; | 326 return false; |
| 327 } | 327 } |
| 328 capture_states_[video_capturer] = capture_state; | 328 capture_states_[video_capturer] = capture_state; |
| 329 SignalCapturerStateChange.repeat(video_capturer->SignalStateChange); | 329 SignalCapturerStateChange.repeat(video_capturer->SignalStateChange); |
| 330 return true; | 330 return true; |
| 331 } | 331 } |
| 332 | 332 |
| 333 void CaptureManager::UnregisterVideoCapturer( | 333 void CaptureManager::UnregisterVideoCapturer( |
| 334 VideoCapturerState* capture_state) { | 334 VideoCapturerState* capture_state) { |
| 335 DCHECK(thread_checker_.CalledOnValidThread()); | 335 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 336 VideoCapturer* video_capturer = capture_state->GetVideoCapturer(); | 336 VideoCapturer* video_capturer = capture_state->GetVideoCapturer(); |
| 337 capture_states_.erase(video_capturer); | 337 capture_states_.erase(video_capturer); |
| 338 delete capture_state; | 338 delete capture_state; |
| 339 | 339 |
| 340 // When unregistering a VideoCapturer, the CaptureManager needs to unregister | 340 // When unregistering a VideoCapturer, the CaptureManager needs to unregister |
| 341 // from all state change callbacks from the VideoCapturer. E.g. to avoid | 341 // from all state change callbacks from the VideoCapturer. E.g. to avoid |
| 342 // problems with multiple callbacks if registering the same VideoCapturer | 342 // problems with multiple callbacks if registering the same VideoCapturer |
| 343 // multiple times. The VideoCapturer will update the capturer state. However, | 343 // multiple times. The VideoCapturer will update the capturer state. However, |
| 344 // this is done through Post-calls which means it may happen at any time. If | 344 // this is done through Post-calls which means it may happen at any time. If |
| 345 // the CaptureManager no longer is listening to the VideoCapturer it will not | 345 // the CaptureManager no longer is listening to the VideoCapturer it will not |
| 346 // receive those callbacks. Here it is made sure that the the callback is | 346 // receive those callbacks. Here it is made sure that the the callback is |
| 347 // indeed sent by letting the ChannelManager do the signaling. The downside is | 347 // indeed sent by letting the ChannelManager do the signaling. The downside is |
| 348 // that the callback may happen before the VideoCapturer is stopped. However, | 348 // that the callback may happen before the VideoCapturer is stopped. However, |
| 349 // for the CaptureManager it doesn't matter as it will no longer receive any | 349 // for the CaptureManager it doesn't matter as it will no longer receive any |
| 350 // frames from the VideoCapturer. | 350 // frames from the VideoCapturer. |
| 351 SignalCapturerStateChange.stop(video_capturer->SignalStateChange); | 351 SignalCapturerStateChange.stop(video_capturer->SignalStateChange); |
| 352 if (video_capturer->IsRunning()) { | 352 if (video_capturer->IsRunning()) { |
| 353 video_capturer->Stop(); | 353 video_capturer->Stop(); |
| 354 SignalCapturerStateChange(video_capturer, CS_STOPPED); | 354 SignalCapturerStateChange(video_capturer, CS_STOPPED); |
| 355 } | 355 } |
| 356 } | 356 } |
| 357 | 357 |
| 358 bool CaptureManager::StartWithBestCaptureFormat( | 358 bool CaptureManager::StartWithBestCaptureFormat( |
| 359 VideoCapturerState* capture_state, VideoCapturer* video_capturer) { | 359 VideoCapturerState* capture_state, VideoCapturer* video_capturer) { |
| 360 DCHECK(thread_checker_.CalledOnValidThread()); | 360 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 361 VideoFormat highest_asked_format = | 361 VideoFormat highest_asked_format = |
| 362 capture_state->GetHighestFormat(video_capturer); | 362 capture_state->GetHighestFormat(video_capturer); |
| 363 VideoFormat capture_format; | 363 VideoFormat capture_format; |
| 364 if (!video_capturer->GetBestCaptureFormat(highest_asked_format, | 364 if (!video_capturer->GetBestCaptureFormat(highest_asked_format, |
| 365 &capture_format)) { | 365 &capture_format)) { |
| 366 LOG(LS_WARNING) << "Unsupported format:" | 366 LOG(LS_WARNING) << "Unsupported format:" |
| 367 << " width=" << highest_asked_format.width | 367 << " width=" << highest_asked_format.width |
| 368 << " height=" << highest_asked_format.height | 368 << " height=" << highest_asked_format.height |
| 369 << ". Supported formats are:"; | 369 << ". Supported formats are:"; |
| 370 const std::vector<VideoFormat>* formats = | 370 const std::vector<VideoFormat>* formats = |
| 371 video_capturer->GetSupportedFormats(); | 371 video_capturer->GetSupportedFormats(); |
| 372 ASSERT(formats != NULL); | 372 ASSERT(formats != NULL); |
| 373 for (std::vector<VideoFormat>::const_iterator i = formats->begin(); | 373 for (std::vector<VideoFormat>::const_iterator i = formats->begin(); |
| 374 i != formats->end(); ++i) { | 374 i != formats->end(); ++i) { |
| 375 const VideoFormat& format = *i; | 375 const VideoFormat& format = *i; |
| 376 LOG(LS_WARNING) << " " << GetFourccName(format.fourcc) | 376 LOG(LS_WARNING) << " " << GetFourccName(format.fourcc) |
| 377 << ":" << format.width << "x" << format.height << "x" | 377 << ":" << format.width << "x" << format.height << "x" |
| 378 << format.framerate(); | 378 << format.framerate(); |
| 379 } | 379 } |
| 380 return false; | 380 return false; |
| 381 } | 381 } |
| 382 return video_capturer->StartCapturing(capture_format); | 382 return video_capturer->StartCapturing(capture_format); |
| 383 } | 383 } |
| 384 | 384 |
| 385 VideoCapturerState* CaptureManager::GetCaptureState( | 385 VideoCapturerState* CaptureManager::GetCaptureState( |
| 386 VideoCapturer* video_capturer) const { | 386 VideoCapturer* video_capturer) const { |
| 387 DCHECK(thread_checker_.CalledOnValidThread()); | 387 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 388 CaptureStates::const_iterator iter = capture_states_.find(video_capturer); | 388 CaptureStates::const_iterator iter = capture_states_.find(video_capturer); |
| 389 if (iter == capture_states_.end()) { | 389 if (iter == capture_states_.end()) { |
| 390 return NULL; | 390 return NULL; |
| 391 } | 391 } |
| 392 return iter->second; | 392 return iter->second; |
| 393 } | 393 } |
| 394 | 394 |
| 395 CaptureRenderAdapter* CaptureManager::GetAdapter( | 395 CaptureRenderAdapter* CaptureManager::GetAdapter( |
| 396 VideoCapturer* video_capturer) const { | 396 VideoCapturer* video_capturer) const { |
| 397 DCHECK(thread_checker_.CalledOnValidThread()); | 397 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 398 VideoCapturerState* capture_state = GetCaptureState(video_capturer); | 398 VideoCapturerState* capture_state = GetCaptureState(video_capturer); |
| 399 if (!capture_state) { | 399 if (!capture_state) { |
| 400 return NULL; | 400 return NULL; |
| 401 } | 401 } |
| 402 return capture_state->adapter(); | 402 return capture_state->adapter(); |
| 403 } | 403 } |
| 404 | 404 |
| 405 } // namespace cricket | 405 } // namespace cricket |
| OLD | NEW |