- add sources.
[platform/framework/web/crosswalk.git] / src / content / renderer / media / rtc_video_capturer.h
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.
4
5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURER_H_
6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURER_H_
7
8 #include <vector>
9
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"
13
14 namespace content {
15 class VideoCaptureImplManager;
16
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 {
25  public:
26   RtcVideoCapturer(const media::VideoCaptureSessionId id,
27                    VideoCaptureImplManager* vc_manager,
28                    bool is_screencast);
29   virtual ~RtcVideoCapturer();
30
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;
41
42  private:
43   // Frame captured callback method.
44   virtual void OnFrameCaptured(const scoped_refptr<media::VideoFrame>& frame);
45
46   // State change callback, must be called on same thread as Start is called.
47   void OnStateChange(RtcVideoCaptureDelegate::CaptureState state);
48
49   const bool is_screencast_;
50   scoped_refptr<RtcVideoCaptureDelegate> delegate_;
51   VideoCaptureState state_;
52   base::TimeDelta first_frame_timestamp_;
53
54   DISALLOW_COPY_AND_ASSIGN(RtcVideoCapturer);
55 };
56
57 }  // namespace content
58
59 #endif  // CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURER_H_