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_TRACK_ADAPTER_H_ 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_TRACK_ADAPTER_H_ 7 8 #include "base/macros.h" 9 #include "base/threading/thread_checker.h" 10 #include "content/public/renderer/media_stream_video_sink.h" 11 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" 12 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" 13 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 14 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" 15 #include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h" 16 17 namespace content { 18 19 class MediaStreamVideoTrack; 20 21 // WebRtcVideoTrackAdapter is an adapter between a 22 // content::MediaStreamVideoTrack object and a webrtc VideoTrack that is 23 // currently sent on a PeerConnection. 24 // The responsibility of the class is to create and own a representation of a 25 // webrtc VideoTrack that can be added and removed from a RTCPeerConnection. 26 // An instance of WebRtcVideoTrackAdapter is created when a VideoTrack is 27 // added to an RTCPeerConnection object. 28 // Instances of this class is owned by the WebRtcMediaStreamAdapter object that 29 // created it. 30 class WebRtcVideoTrackAdapter : public MediaStreamVideoSink { 31 public: 32 WebRtcVideoTrackAdapter(const blink::WebMediaStreamTrack& track, 33 PeerConnectionDependencyFactory* factory); 34 virtual ~WebRtcVideoTrackAdapter(); 35 36 webrtc::VideoTrackInterface* webrtc_video_track() { 37 return video_track_.get(); 38 } 39 40 protected: 41 // Implementation of MediaStreamSink. 42 virtual void OnEnabledChanged(bool enabled) OVERRIDE; 43 44 private: 45 // Used to DCHECK that we are called on the correct thread. 46 base::ThreadChecker thread_checker_; 47 48 scoped_refptr<webrtc::VideoTrackInterface> video_track_; 49 blink::WebMediaStreamTrack web_track_; 50 51 class WebRtcVideoSourceAdapter; 52 scoped_refptr<WebRtcVideoSourceAdapter> source_adapter_; 53 54 DISALLOW_COPY_AND_ASSIGN(WebRtcVideoTrackAdapter); 55 }; 56 57 } // namespace content 58 59 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_TRACK_ADAPTER_H_ 60