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

Unified Diff: media/capture/video/mac/video_capture_device_decklink_mac.mm

Issue 2673373003: getUserMeida: report device starting states (Closed)
Patch Set: address comments on PS#4 and revise unittests Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: media/capture/video/mac/video_capture_device_decklink_mac.mm
diff --git a/media/capture/video/mac/video_capture_device_decklink_mac.mm b/media/capture/video/mac/video_capture_device_decklink_mac.mm
index 54bb0ccde568fb563bbc9f8faffed7bc44c8fa1f..b6eefdca46210bef6994b6bf795b688c7a848432 100644
--- a/media/capture/video/mac/video_capture_device_decklink_mac.mm
+++ b/media/capture/video/mac/video_capture_device_decklink_mac.mm
@@ -98,6 +98,8 @@ class DeckLinkCaptureDelegate
// Checks for Device (a.k.a. Audio) thread.
base::ThreadChecker thread_checker_;
+ bool capture_;
+
friend class scoped_refptr<DeckLinkCaptureDelegate>;
friend class base::RefCountedThreadSafe<DeckLinkCaptureDelegate>;
@@ -126,7 +128,9 @@ static float GetDisplayModeFrameRate(
DeckLinkCaptureDelegate::DeckLinkCaptureDelegate(
const media::VideoCaptureDeviceDescriptor& device_descriptor,
media::VideoCaptureDeviceDeckLinkMac* frame_receiver)
- : device_descriptor_(device_descriptor), frame_receiver_(frame_receiver) {}
+ : device_descriptor_(device_descriptor),
+ frame_receiver_(frame_receiver),
+ capture_(false) {}
DeckLinkCaptureDelegate::~DeckLinkCaptureDelegate() {
}
@@ -209,12 +213,18 @@ void DeckLinkCaptureDelegate::AllocateAndStart(
if (decklink_input_local->StartStreams() != S_OK)
SendErrorString(FROM_HERE, "Could not start capturing");
+ if (frame_receiver_)
+ frame_receiver_->ReportStarted();
+
+ capture_ = true;
+
decklink_.swap(decklink_local);
decklink_input_.swap(decklink_input_local);
}
void DeckLinkCaptureDelegate::StopAndDeAllocate() {
DCHECK(thread_checker_.CalledOnValidThread());
+ capture_ = false;
if (!decklink_input_.get())
return;
if (decklink_input_->StopStreams() != S_OK)
@@ -237,6 +247,9 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFormatChanged(
HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(
IDeckLinkVideoInputFrame* video_frame,
IDeckLinkAudioInputPacket* /* audio_packet */) {
+ if (!capture_)
+ return S_OK;
+
// Capture frames are manipulated as an IDeckLinkVideoFrame.
uint8_t* video_data = NULL;
video_frame->GetBytes(reinterpret_cast<void**>(&video_data));
@@ -494,6 +507,13 @@ void VideoCaptureDeviceDeckLinkMac::SendLogString(const std::string& message) {
client_->OnLog(message);
}
+void VideoCaptureDeviceDeckLinkMac::ReportStarted() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ base::AutoLock lock(lock_);
+ if (client_)
+ client_->OnStarted();
+}
+
void VideoCaptureDeviceDeckLinkMac::AllocateAndStart(
const VideoCaptureParams& params,
std::unique_ptr<VideoCaptureDevice::Client> client) {

Powered by Google App Engine
This is Rietveld 408576698