#ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_
#define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_
#include <vector>
#include "base/compiler_specific.h"
#include "base/memory/scoped_vector.h"
#include "base/threading/thread_checker.h"
#include "content/common/content_export.h"
#include "content/public/renderer/media_stream_video_sink.h"
#include "content/renderer/media/media_stream_track.h"
#include "content/renderer/media/media_stream_video_source.h"
namespace webrtc {
class VideoTrackInterface;
}
namespace content {
class MediaStreamDependencyFactory;
class WebRtcVideoSinkAdapter;
class CONTENT_EXPORT MediaStreamVideoTrack : public MediaStreamTrack {
public:
static blink::WebMediaStreamTrack CreateVideoTrack(
MediaStreamVideoSource* source,
const blink::WebMediaConstraints& constraints,
const MediaStreamVideoSource::ConstraintsCallback& callback,
bool enabled,
MediaStreamDependencyFactory* factory);
static MediaStreamVideoTrack* GetVideoTrack(
const blink::WebMediaStreamTrack& track);
MediaStreamVideoTrack(
MediaStreamVideoSource* source,
const blink::WebMediaConstraints& constraints,
const MediaStreamVideoSource::ConstraintsCallback& callback,
bool enabled,
MediaStreamDependencyFactory* factory);
virtual ~MediaStreamVideoTrack();
virtual void AddSink(MediaStreamVideoSink* sink);
virtual void RemoveSink(MediaStreamVideoSink* sink);
virtual webrtc::VideoTrackInterface* GetVideoAdapter() OVERRIDE;
virtual void SetEnabled(bool enabled) OVERRIDE;
void OnVideoFrame(const scoped_refptr<media::VideoFrame>& frame);
void OnReadyStateChanged(blink::WebMediaStreamSource::ReadyState state);
protected:
base::ThreadChecker thread_checker_;
private:
bool enabled_;
std::vector<MediaStreamVideoSink*> sinks_;
MediaStreamVideoSource* source_;
MediaStreamDependencyFactory* factory_;
DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoTrack);
};
class CONTENT_EXPORT WebRtcMediaStreamVideoTrack
: public MediaStreamVideoTrack {
public:
explicit WebRtcMediaStreamVideoTrack(webrtc::VideoTrackInterface* track);
virtual ~WebRtcMediaStreamVideoTrack();
virtual void AddSink(MediaStreamVideoSink* sink) OVERRIDE;
virtual void RemoveSink(MediaStreamVideoSink* sink) OVERRIDE;
private:
ScopedVector<WebRtcVideoSinkAdapter> sinks_;
DISALLOW_COPY_AND_ASSIGN(WebRtcMediaStreamVideoTrack);
};
}
#endif