Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_SOURCE_H_ | |
| 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_SOURCE_H_ | |
| 7 | |
| 8 #include "content/common/content_export.h" | |
| 9 #include "third_party/libjingle/source/talk/app/webrtc/notifier.h" | |
| 10 #include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h" | |
| 11 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | |
| 12 #include "third_party/libjingle/source/talk/base/criticalsection.h" | |
| 13 | |
| 14 namespace cricket { | |
| 15 class VideoCapturer; | |
| 16 class VideoRenderer; | |
| 17 class VideoOptions; | |
| 18 class VideoFrame; | |
| 19 } | |
| 20 | |
| 21 namespace content { | |
| 22 | |
| 23 // WebRtcVideoSource implements VideoSourceInterface. | |
| 24 // The different between this and webrtc::VideoSource is that this one gets | |
|
Jói
2014/01/09 11:18:13
different between -> difference between
| |
| 25 // frame only from the |FrameInput()| interface (i.e. there's not real capturer | |
| 26 // attached to it) and it doesn't involve cricket stuff e.g. the | |
| 27 // cricket::ChannelManager. | |
| 28 // TODO(ronghuawu): Remove |GetVideoCapturer()| from | |
| 29 // webrtc::VideoSourceInterface. Deliver video frames to media engine instead | |
| 30 // of connecting media engine with the capturer directly. | |
| 31 class CONTENT_EXPORT WebRtcVideoSource | |
| 32 : NON_EXPORTED_BASE(public webrtc::Notifier<webrtc::VideoSourceInterface>), | |
| 33 NON_EXPORTED_BASE(public sigslot::has_slots<>) { | |
| 34 public: | |
| 35 // Creates an instance of WebRtcVideoSource. | |
| 36 static talk_base::scoped_refptr<WebRtcVideoSource> Create(); | |
| 37 | |
| 38 WebRtcVideoSource(); | |
| 39 virtual ~WebRtcVideoSource(); | |
| 40 | |
| 41 // Implements webrtc::VideoSourceInterface | |
| 42 virtual cricket::VideoCapturer* GetVideoCapturer(); | |
| 43 virtual void AddSink(cricket::VideoRenderer* output); | |
| 44 virtual void RemoveSink(cricket::VideoRenderer* output); | |
| 45 virtual const cricket::VideoOptions* options() const; | |
| 46 virtual webrtc::MediaSourceInterface::SourceState state() const; | |
| 47 virtual cricket::VideoRenderer* FrameInput(); | |
| 48 | |
| 49 private: | |
| 50 struct VideoSinkInfo { | |
| 51 explicit VideoSinkInfo(cricket::VideoRenderer* s) | |
| 52 : sink(s), | |
| 53 width(0), | |
| 54 height(0) { | |
| 55 } | |
| 56 cricket::VideoRenderer* sink; | |
| 57 size_t width; | |
| 58 size_t height; | |
| 59 }; | |
| 60 | |
| 61 // Just pointers since ownership is not handed over to this class. | |
| 62 typedef std::vector<VideoSinkInfo> VideoSinks; | |
| 63 | |
| 64 // Callback for frames received from the FrameInput interface. | |
| 65 void OnVideoFrame(cricket::VideoCapturer* capturer, | |
| 66 const cricket::VideoFrame* video_frame); | |
| 67 | |
| 68 void MaybeSetSize(const cricket::VideoFrame* frame); | |
| 69 | |
| 70 talk_base::scoped_ptr<cricket::VideoCapturer> video_capturer_; | |
| 71 talk_base::scoped_ptr<cricket::VideoRenderer> frame_input_; | |
| 72 cricket::VideoOptions options_; | |
| 73 webrtc::MediaSourceInterface::SourceState state_; | |
| 74 VideoSinks sinks_; | |
| 75 talk_base::CriticalSection sinks_crit_; | |
| 76 }; | |
| 77 | |
| 78 } // namespace content | |
| 79 | |
| 80 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_SOURCE_H_ | |
| OLD | NEW |