| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "webrtc/base/thread.h" | 42 #include "webrtc/base/thread.h" |
| 43 #include "webrtc/base/timeutils.h" | 43 #include "webrtc/base/timeutils.h" |
| 44 | 44 |
| 45 #include "webrtc/base/win32.h" // Need this to #include the impl files. | 45 #include "webrtc/base/win32.h" // Need this to #include the impl files. |
| 46 #include "webrtc/modules/video_capture/include/video_capture_factory.h" | 46 #include "webrtc/modules/video_capture/include/video_capture_factory.h" |
| 47 #include "webrtc/system_wrappers/interface/field_trial.h" | 47 #include "webrtc/system_wrappers/interface/field_trial.h" |
| 48 | 48 |
| 49 namespace cricket { | 49 namespace cricket { |
| 50 | 50 |
| 51 struct kVideoFourCCEntry { | 51 struct kVideoFourCCEntry { |
| 52 uint32 fourcc; | 52 uint32_t fourcc; |
| 53 webrtc::RawVideoType webrtc_type; | 53 webrtc::RawVideoType webrtc_type; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // This indicates our format preferences and defines a mapping between | 56 // This indicates our format preferences and defines a mapping between |
| 57 // webrtc::RawVideoType (from video_capture_defines.h) to our FOURCCs. | 57 // webrtc::RawVideoType (from video_capture_defines.h) to our FOURCCs. |
| 58 static kVideoFourCCEntry kSupportedFourCCs[] = { | 58 static kVideoFourCCEntry kSupportedFourCCs[] = { |
| 59 { FOURCC_I420, webrtc::kVideoI420 }, // 12 bpp, no conversion. | 59 { FOURCC_I420, webrtc::kVideoI420 }, // 12 bpp, no conversion. |
| 60 { FOURCC_YV12, webrtc::kVideoYV12 }, // 12 bpp, no conversion. | 60 { FOURCC_YV12, webrtc::kVideoYV12 }, // 12 bpp, no conversion. |
| 61 { FOURCC_YUY2, webrtc::kVideoYUY2 }, // 16 bpp, fast conversion. | 61 { FOURCC_YUY2, webrtc::kVideoYUY2 }, // 16 bpp, fast conversion. |
| 62 { FOURCC_UYVY, webrtc::kVideoUYVY }, // 16 bpp, fast conversion. | 62 { FOURCC_UYVY, webrtc::kVideoUYVY }, // 16 bpp, fast conversion. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 75 virtual webrtc::VideoCaptureModule::DeviceInfo* CreateDeviceInfo(int id) { | 75 virtual webrtc::VideoCaptureModule::DeviceInfo* CreateDeviceInfo(int id) { |
| 76 return webrtc::VideoCaptureFactory::CreateDeviceInfo(id); | 76 return webrtc::VideoCaptureFactory::CreateDeviceInfo(id); |
| 77 } | 77 } |
| 78 virtual void DestroyDeviceInfo(webrtc::VideoCaptureModule::DeviceInfo* info) { | 78 virtual void DestroyDeviceInfo(webrtc::VideoCaptureModule::DeviceInfo* info) { |
| 79 delete info; | 79 delete info; |
| 80 } | 80 } |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 static bool CapabilityToFormat(const webrtc::VideoCaptureCapability& cap, | 83 static bool CapabilityToFormat(const webrtc::VideoCaptureCapability& cap, |
| 84 VideoFormat* format) { | 84 VideoFormat* format) { |
| 85 uint32 fourcc = 0; | 85 uint32_t fourcc = 0; |
| 86 for (size_t i = 0; i < ARRAY_SIZE(kSupportedFourCCs); ++i) { | 86 for (size_t i = 0; i < ARRAY_SIZE(kSupportedFourCCs); ++i) { |
| 87 if (kSupportedFourCCs[i].webrtc_type == cap.rawType) { | 87 if (kSupportedFourCCs[i].webrtc_type == cap.rawType) { |
| 88 fourcc = kSupportedFourCCs[i].fourcc; | 88 fourcc = kSupportedFourCCs[i].fourcc; |
| 89 break; | 89 break; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 if (fourcc == 0) { | 92 if (fourcc == 0) { |
| 93 return false; | 93 return false; |
| 94 } | 94 } |
| 95 | 95 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 captured_frames_ = 0; | 296 captured_frames_ = 0; |
| 297 | 297 |
| 298 SetCaptureFormat(&capture_format); | 298 SetCaptureFormat(&capture_format); |
| 299 | 299 |
| 300 webrtc::VideoCaptureCapability cap; | 300 webrtc::VideoCaptureCapability cap; |
| 301 if (!FormatToCapability(capture_format, &cap)) { | 301 if (!FormatToCapability(capture_format, &cap)) { |
| 302 LOG(LS_ERROR) << "Invalid capture format specified"; | 302 LOG(LS_ERROR) << "Invalid capture format specified"; |
| 303 return CS_FAILED; | 303 return CS_FAILED; |
| 304 } | 304 } |
| 305 | 305 |
| 306 uint32 start = rtc::Time(); | 306 uint32_t start = rtc::Time(); |
| 307 module_->RegisterCaptureDataCallback(*this); | 307 module_->RegisterCaptureDataCallback(*this); |
| 308 if (module_->StartCapture(cap) != 0) { | 308 if (module_->StartCapture(cap) != 0) { |
| 309 LOG(LS_ERROR) << "Camera '" << GetId() << "' failed to start"; | 309 LOG(LS_ERROR) << "Camera '" << GetId() << "' failed to start"; |
| 310 module_->DeRegisterCaptureDataCallback(); | 310 module_->DeRegisterCaptureDataCallback(); |
| 311 async_invoker_.reset(); | 311 async_invoker_.reset(); |
| 312 SetCaptureFormat(nullptr); | 312 SetCaptureFormat(nullptr); |
| 313 start_thread_ = nullptr; | 313 start_thread_ = nullptr; |
| 314 return CS_FAILED; | 314 return CS_FAILED; |
| 315 } | 315 } |
| 316 | 316 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 async_invoker_.reset(); | 348 async_invoker_.reset(); |
| 349 | 349 |
| 350 SetCaptureFormat(NULL); | 350 SetCaptureFormat(NULL); |
| 351 start_thread_ = nullptr; | 351 start_thread_ = nullptr; |
| 352 } | 352 } |
| 353 | 353 |
| 354 bool WebRtcVideoCapturer::IsRunning() { | 354 bool WebRtcVideoCapturer::IsRunning() { |
| 355 return (module_ != NULL && module_->CaptureStarted()); | 355 return (module_ != NULL && module_->CaptureStarted()); |
| 356 } | 356 } |
| 357 | 357 |
| 358 bool WebRtcVideoCapturer::GetPreferredFourccs( | 358 bool WebRtcVideoCapturer::GetPreferredFourccs(std::vector<uint32_t>* fourccs) { |
| 359 std::vector<uint32>* fourccs) { | |
| 360 if (!fourccs) { | 359 if (!fourccs) { |
| 361 return false; | 360 return false; |
| 362 } | 361 } |
| 363 | 362 |
| 364 fourccs->clear(); | 363 fourccs->clear(); |
| 365 for (size_t i = 0; i < ARRAY_SIZE(kSupportedFourCCs); ++i) { | 364 for (size_t i = 0; i < ARRAY_SIZE(kSupportedFourCCs); ++i) { |
| 366 fourccs->push_back(kSupportedFourCCs[i].fourcc); | 365 fourccs->push_back(kSupportedFourCCs[i].fourcc); |
| 367 } | 366 } |
| 368 return true; | 367 return true; |
| 369 } | 368 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 void* buffer, | 427 void* buffer, |
| 429 size_t length) { | 428 size_t length) { |
| 430 width = sample.width(); | 429 width = sample.width(); |
| 431 height = sample.height(); | 430 height = sample.height(); |
| 432 fourcc = FOURCC_I420; | 431 fourcc = FOURCC_I420; |
| 433 // TODO(hellner): Support pixel aspect ratio (for OSX). | 432 // TODO(hellner): Support pixel aspect ratio (for OSX). |
| 434 pixel_width = 1; | 433 pixel_width = 1; |
| 435 pixel_height = 1; | 434 pixel_height = 1; |
| 436 // Convert units from VideoFrame RenderTimeMs to CapturedFrame (nanoseconds). | 435 // Convert units from VideoFrame RenderTimeMs to CapturedFrame (nanoseconds). |
| 437 time_stamp = sample.render_time_ms() * rtc::kNumNanosecsPerMillisec; | 436 time_stamp = sample.render_time_ms() * rtc::kNumNanosecsPerMillisec; |
| 438 data_size = rtc::checked_cast<uint32>(length); | 437 data_size = rtc::checked_cast<uint32_t>(length); |
| 439 data = buffer; | 438 data = buffer; |
| 440 rotation = sample.rotation(); | 439 rotation = sample.rotation(); |
| 441 } | 440 } |
| 442 | 441 |
| 443 } // namespace cricket | 442 } // namespace cricket |
| 444 | 443 |
| 445 #endif // HAVE_WEBRTC_VIDEO | 444 #endif // HAVE_WEBRTC_VIDEO |
| OLD | NEW |