8b6daf9c19a0c4bf6513280189f7e5d78f09fcf4
[platform/framework/web/crosswalk-tizen.git] /
1 // Copyright 2017 Samsung Electronics Inc. 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 MEDIA_BASE_TIZEN_MEDIA_PLAYER_INTERFACE_EFL_H_
6 #define MEDIA_BASE_TIZEN_MEDIA_PLAYER_INTERFACE_EFL_H_
7
8 #include "base/time/time.h"
9 #include "base/tizen/flags.h"
10
11 #if defined(TIZEN_SOUND_FOCUS)
12 #include "media/base/tizen/sound_focus_manager.h"
13 #endif
14
15 namespace gfx {
16 class RectF;
17 }
18
19 namespace media {
20
21 enum class MediaType {
22   Video = 0x1,
23   Audio = Video << 1,
24 };
25
26 using MediaTypeFlags = base::Flags<MediaType>;
27 DEFINE_OPERATORS_FOR_FLAGS(MediaTypeFlags);
28
29 class MediaPlayerInterfaceEfl
30 #if defined(TIZEN_SOUND_FOCUS)
31     : public SoundFocusClient
32 #endif
33 {
34  public:
35   virtual ~MediaPlayerInterfaceEfl() = default;
36
37   virtual int GetPlayerId() const = 0;
38
39   // Initialize a player to prepare it for accepting playback commands.
40   virtual void Initialize() = 0;
41
42   // Start playing the media.
43   virtual void Play() = 0;
44
45   // Pause the player. If |is_media_related_action| is set to |true| it
46   // indicates that the player itself needs to pause to buffer. |false| means
47   // that HTMLMediaElement has requested the player to pause.
48   virtual void Pause(bool is_media_related_action) = 0;
49
50   // Set playback rate.
51   virtual void SetRate(double rate) = 0;
52
53   // Seek to a particular position based on renderer signaling actual seek.
54   // If the player finishes seeking, OnSeekComplete() will be called.
55   virtual void Seek(base::TimeDelta time) = 0;
56
57   // Set the player audio volume.
58   virtual void SetVolume(double volume) = 0;
59
60   // Get the current playback position.
61   virtual base::TimeDelta GetCurrentTime() = 0;
62
63   // The player is now displayed in fullscreen.
64   virtual void EnteredFullscreen() = 0;
65
66   // The player is back to a normal display mode.
67   virtual void ExitedFullscreen() = 0;
68
69   // Interface for resource handling
70
71   // Return the type of media which this player currently plays and needs.
72   // resources for.
73   virtual MediaTypeFlags GetMediaType() const = 0;
74
75   // Free all the resources returned by |GetMediaType|.
76   virtual void Suspend() = 0;
77
78   // Reallocate resources after they have been freed using |Suspend|. The
79   // player needs all the resouces as returned by |GetMediaType|.
80   virtual void Resume() = 0;
81
82   // Return whether the player is playing or is it in pause state.
83   virtual bool IsPaused() const = 0;
84
85   // Return whether the player should call seek after resume
86   virtual bool ShouldSeekAfterResume() const = 0;
87
88 #if defined(TIZEN_VIDEO_HOLE)
89   virtual void SetGeometry(const gfx::RectF&) = 0;
90   virtual void OnWebViewMoved() = 0;
91 #endif
92
93 #if defined(TIZEN_SOUND_FOCUS)
94   virtual void SetResumePlayingBySFM(bool resume_playing) = 0;
95 #endif
96
97   virtual double GetStartDate() = 0;
98
99   virtual bool HasConfigs() const = 0;
100
101 #if defined(TIZEN_MULTIMEDIA_SUPPORT)
102   // Launch native system volume controller.
103   virtual void LaunchSystemVolumeController() = 0;
104 #endif
105
106 };
107
108 }  // namespace media
109
110 namespace std {
111 inline ostream& operator<<(ostream& o, media::MediaType type) {
112   switch (type) {
113     case media::MediaType::Video:
114       return o << 'V';
115     case media::MediaType::Audio:
116       return o << 'A';
117   }
118   return o << "MediaType(" << (int)type << ")";
119 }
120 }
121
122 #endif  // MEDIA_BASE_TIZEN_MEDIA_PLAYER_INTERFACE_EFL_H_