#ifndef CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_
#define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
#include "cc/layers/video_frame_provider.h"
#include "media/filters/skcanvas_video_renderer.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/public/platform/WebMediaPlayer.h"
#include "url/gurl.h"
namespace blink {
class WebFrame;
class WebMediaPlayerClient;
}
namespace media {
class MediaLog;
}
namespace webkit {
class WebLayerImpl;
}
namespace content {
class MediaStreamAudioRenderer;
class MediaStreamClient;
class VideoFrameProvider;
class WebMediaPlayerDelegate;
class WebMediaPlayerMS
: public blink::WebMediaPlayer,
public cc::VideoFrameProvider,
public base::SupportsWeakPtr<WebMediaPlayerMS> {
public:
WebMediaPlayerMS(blink::WebFrame* frame,
blink::WebMediaPlayerClient* client,
base::WeakPtr<WebMediaPlayerDelegate> delegate,
MediaStreamClient* media_stream_client,
media::MediaLog* media_log);
virtual ~WebMediaPlayerMS();
virtual void load(LoadType load_type,
const blink::WebURL& url,
CORSMode cors_mode);
virtual void play();
virtual void pause();
virtual bool supportsSave() const;
virtual void seek(double seconds);
virtual void setRate(double rate);
virtual void setVolume(double volume);
virtual void setPreload(blink::WebMediaPlayer::Preload preload);
virtual const blink::WebTimeRanges& buffered();
virtual double maxTimeSeekable() const;
virtual void paint(blink::WebCanvas* canvas,
const blink::WebRect& rect,
unsigned char alpha);
virtual bool hasVideo() const;
virtual bool hasAudio() const;
virtual blink::WebSize naturalSize() const;
virtual bool paused() const;
virtual bool seeking() const;
virtual double duration() const;
virtual double currentTime() const;
virtual blink::WebMediaPlayer::NetworkState networkState() const;
virtual blink::WebMediaPlayer::ReadyState readyState() const;
virtual bool didLoadingProgress() const;
virtual bool hasSingleSecurityOrigin() const;
virtual bool didPassCORSAccessCheck() const;
virtual double mediaTimeForTimeValue(double timeValue) const;
virtual unsigned decodedFrameCount() const;
virtual unsigned droppedFrameCount() const;
virtual unsigned audioDecodedByteCount() const;
virtual unsigned videoDecodedByteCount() const;
virtual void SetVideoFrameProviderClient(
cc::VideoFrameProvider::Client* client) OVERRIDE;
virtual scoped_refptr<media::VideoFrame> GetCurrentFrame() OVERRIDE;
virtual void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame)
OVERRIDE;
private:
void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame);
void RepaintInternal();
void OnSourceError();
void SetNetworkState(blink::WebMediaPlayer::NetworkState state);
void SetReadyState(blink::WebMediaPlayer::ReadyState state);
blink::WebMediaPlayerClient* GetClient();
blink::WebFrame* frame_;
blink::WebMediaPlayer::NetworkState network_state_;
blink::WebMediaPlayer::ReadyState ready_state_;
blink::WebTimeRanges buffered_;
base::ThreadChecker thread_checker_;
blink::WebMediaPlayerClient* client_;
base::WeakPtr<WebMediaPlayerDelegate> delegate_;
MediaStreamClient* media_stream_client_;
scoped_refptr<content::VideoFrameProvider> video_frame_provider_;
bool paused_;
scoped_refptr<media::VideoFrame> current_frame_;
bool current_frame_used_;
base::Lock current_frame_lock_;
bool pending_repaint_;
scoped_ptr<webkit::WebLayerImpl> video_weblayer_;
cc::VideoFrameProvider::Client* video_frame_provider_client_;
bool received_first_frame_;
bool sequence_started_;
base::TimeDelta start_time_;
base::TimeDelta current_time_;
unsigned total_frame_count_;
unsigned dropped_frame_count_;
media::SkCanvasVideoRenderer video_renderer_;
scoped_refptr<MediaStreamAudioRenderer> audio_renderer_;
scoped_refptr<media::MediaLog> media_log_;
DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS);
};
}
#endif