1 // Copyright (c) 2012 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_RTC_VIDEO_CAPTURER_H_
6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURER_H_
10 #include "base/compiler_specific.h"
11 #include "content/renderer/media/rtc_video_capture_delegate.h"
12 #include "third_party/libjingle/source/talk/media/base/videocapturer.h"
16 // RtcVideoCapturer implements a simple cricket::VideoCapturer that is used for
17 // VideoCapturing in libJingle and especially in PeerConnections.
18 // The class is created and destroyed on the main render thread.
19 // PeerConnection access cricket::VideoCapturer from a libJingle worker thread.
20 // The video frames are delivered in OnFrameCaptured on a thread owned by
21 // Chrome's video capture implementation.
22 class RtcVideoCapturer
23 : public cricket::VideoCapturer
{
25 RtcVideoCapturer(const media::VideoCaptureSessionId id
,
27 virtual ~RtcVideoCapturer();
29 // cricket::VideoCapturer implementation.
30 // These methods are accessed from a libJingle worker thread.
31 virtual cricket::CaptureState
Start(
32 const cricket::VideoFormat
& capture_format
) OVERRIDE
;
33 virtual void Stop() OVERRIDE
;
34 virtual bool IsRunning() OVERRIDE
;
35 virtual bool GetPreferredFourccs(std::vector
<uint32
>* fourccs
) OVERRIDE
;
36 virtual bool GetBestCaptureFormat(const cricket::VideoFormat
& desired
,
37 cricket::VideoFormat
* best_format
) OVERRIDE
;
38 virtual bool IsScreencast() const OVERRIDE
;
41 // Frame captured callback method.
42 virtual void OnFrameCaptured(const scoped_refptr
<media::VideoFrame
>& frame
);
44 // State change callback, must be called on same thread as Start is called.
45 void OnStateChange(RtcVideoCaptureDelegate::CaptureState state
);
47 const bool is_screencast_
;
48 scoped_refptr
<RtcVideoCaptureDelegate
> delegate_
;
49 VideoCaptureState state_
;
50 base::TimeDelta first_frame_timestamp_
;
52 DISALLOW_COPY_AND_ASSIGN(RtcVideoCapturer
);
55 } // namespace content
57 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURER_H_