summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webmediaplayer_delegate.h
blob: c86b0016c36c0fea372534acbf07505093bca1ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright (c) 2008 The Chromium Authors. All rights reserved.  Use of this
// source code is governed by a BSD-style license that can be found in the
// LICENSE file.

#ifndef WEBKIT_GLUE_WEBMEDIAPLAYER_DELEGATE_H_
#define WEBKIT_GLUE_WEBMEDIAPLAYER_DELEGATE_H_

#include "base/gfx/platform_canvas.h"
#include "webkit/glue/weberror.h"
#include "webkit/glue/webmediaplayer.h"
#include "webkit/glue/webresponse.h"
#include "webkit/glue/weburlrequest.h"

class GURL;

namespace WebKit {
struct WebRect;
struct WebSize;
}

namespace webkit_glue {

class WebMediaPlayerDelegate {
 public:
  WebMediaPlayerDelegate() {}
  virtual ~WebMediaPlayerDelegate() {}

  virtual void Initialize(WebMediaPlayer *web_media_player) = 0;

  virtual void Load(const GURL& url) = 0;
  virtual void CancelLoad() = 0;

  // Playback controls.
  virtual void Play() = 0;
  virtual void Pause() = 0;
  virtual void Stop() = 0;
  virtual void Seek(float time) = 0;
  virtual void SetEndTime(float time) = 0;
  virtual void SetPlaybackRate(float rate) = 0;
  virtual void SetVolume(float volume) = 0;
  virtual void SetVisible(bool visible) = 0;
  virtual bool IsTotalBytesKnown() = 0;
  virtual float GetMaxTimeBuffered() const = 0;
  virtual float GetMaxTimeSeekable() const = 0;

  // Methods for painting.
  virtual void SetSize(const WebKit::WebSize& size) = 0;

  // TODO(hclam): Using paint at the moment, maybe we just need to return a
  //              SkiaBitmap?
  virtual void Paint(skia::PlatformCanvas *canvas,
                     const WebKit::WebRect& rect) = 0;

  // True if a video is loaded.
  virtual bool IsVideo() const = 0;

  // Dimension of the video.
  virtual size_t GetWidth() const = 0;
  virtual size_t GetHeight() const = 0;

  // Getters fo playback state.
  virtual bool IsPaused() const = 0;
  virtual bool IsSeeking() const = 0;
  virtual float GetDuration() const = 0;
  virtual float GetCurrentTime() const = 0;
  virtual float GetPlayBackRate() const = 0;
  virtual float GetVolume() const = 0;

  // Get rate of loading the resource.
  virtual int32 GetDataRate() const = 0;

  // Internal states of loading and network.
  virtual WebMediaPlayer::NetworkState GetNetworkState() const = 0;
  virtual WebMediaPlayer::ReadyState GetReadyState() const = 0;

  virtual int64 GetBytesLoaded() const = 0;
  virtual int64 GetTotalBytes() const = 0;

 private:
  DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerDelegate);
};

}  // namespace webkit_glue

#endif  // WEBKIT_GLUE_WEBMEDIAPLAYER_DELEGATE_H_