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"
15 class VideoCaptureImplManager;
17 // RtcVideoCapturer implements a simple cricket::VideoCapturer that is used for
18 // VideoCapturing in libJingle and especially in PeerConnections.
19 // The class is created and destroyed on the main render thread.
20 // PeerConnection access cricket::VideoCapturer from a libJingle worker thread.
21 // The video frames are delivered in OnFrameCaptured on a thread owned by
22 // Chrome's video capture implementation.
23 class RtcVideoCapturer
24 : public cricket::VideoCapturer {
26 RtcVideoCapturer(const media::VideoCaptureSessionId id,
27 VideoCaptureImplManager* vc_manager,
29 virtual ~RtcVideoCapturer();
31 // cricket::VideoCapturer implementation.
32 // These methods are accessed from a libJingle worker thread.
33 virtual cricket::CaptureState Start(
34 const cricket::VideoFormat& capture_format) OVERRIDE;
35 virtual void Stop() OVERRIDE;
36 virtual bool IsRunning() OVERRIDE;
37 virtual bool GetPreferredFourccs(std::vector<uint32>* fourccs) OVERRIDE;
38 virtual bool GetBestCaptureFormat(const cricket::VideoFormat& desired,
39 cricket::VideoFormat* best_format) OVERRIDE;
40 virtual bool IsScreencast() const OVERRIDE;
43 // Frame captured callback method.
44 virtual void OnFrameCaptured(const scoped_refptr<media::VideoFrame>& frame);
46 // State change callback, must be called on same thread as Start is called.
47 void OnStateChange(RtcVideoCaptureDelegate::CaptureState state);
49 const bool is_screencast_;
50 scoped_refptr<RtcVideoCaptureDelegate> delegate_;
51 VideoCaptureState state_;
52 base::TimeDelta first_frame_timestamp_;
54 DISALLOW_COPY_AND_ASSIGN(RtcVideoCapturer);
57 } // namespace content
59 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURER_H_