1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_
8 #include "base/callback.h"
9 #include "base/gtest_prod_util.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/thread_checker.h"
12 #include "content/common/media/video_capture.h"
13 #include "content/renderer/media/media_stream_video_source.h"
16 class VideoCapturerSource
;
21 // Representation of a video stream coming from a camera, owned by Blink as
22 // WebMediaStreamSource. Objects of this class are created and live on main
23 // Render thread. Objects can be constructed either by indicating a |device| to
24 // look for, or by plugging in a |source| constructed elsewhere.
25 class CONTENT_EXPORT MediaStreamVideoCapturerSource
26 : public MediaStreamVideoSource
{
28 MediaStreamVideoCapturerSource(const SourceStoppedCallback
& stop_callback
,
29 scoped_ptr
<media::VideoCapturerSource
> source
);
30 MediaStreamVideoCapturerSource(const SourceStoppedCallback
& stop_callback
,
31 const StreamDeviceInfo
& device_info
);
32 virtual ~MediaStreamVideoCapturerSource();
35 friend class MediaStreamVideoCapturerSourceTest
;
37 // Implements MediaStreamVideoSource.
38 void GetCurrentSupportedFormats(
39 int max_requested_width
,
40 int max_requested_height
,
41 double max_requested_frame_rate
,
42 const VideoCaptureDeviceFormatsCB
& callback
) override
;
44 const media::VideoCaptureFormat
& format
,
45 const blink::WebMediaConstraints
& constraints
,
46 const VideoCaptureDeliverFrameCB
& frame_callback
) override
;
47 void StopSourceImpl() override
;
49 // Method to bind as RunningCallback in VideoCapturerSource::StartCapture().
50 void OnStarted(bool result
);
52 const char* GetPowerLineFrequencyForTesting() const;
54 // The source that provides video frames.
55 const scoped_ptr
<media::VideoCapturerSource
> source_
;
57 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoCapturerSource
);
60 } // namespace content
62 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_