Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: media/base/android/media_codec_player_state.h

Issue 1128383003: Implementation of MediaCodecPlayer stage 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unneeded changed to MediaPlayerAndroid, style guide compliance Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_STATE_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_STATE_H_
7
8 #include "base/macros.h"
9 #include "media/base/android/demuxer_android.h"
10 #include "ui/gl/android/scoped_java_surface.h"
11
12 #define DEFINE_INSTANCE(TypeName) \
13 public: \
14 static TypeName * Instance() { \
15 static TypeName singleton; return &singleton; \
16 } \
17 const char* name() override { \
18 return #TypeName ; \
19 } \
20 private: \
21 TypeName() {} \
22 DISALLOW_COPY_AND_ASSIGN(TypeName);
23
24
25 namespace media {
26
27 /*
28
29 --------------------------> Paused
30 | StopDone:
31 | ^ |
32 | | |
33 | Pause: | | Start: dec.Prefetch
34 | | |
35 | | |
36 | | |
37 | | v PrefetchDone,
38 | no surface:
39 | ------------------> Prefetching --------------> Waiting
40 | | for surface
41 | | | /
42 | | | /
43 | | StopDone w/ | /
44 | | pending start: | PrefetchDone: /
45 | | dec.Prefetch | dec.Start /
46 | | | / SetSurface:
47 | | | / dec.Start
48 | | | /
49 | | v /
50 | | /
51 | | Playing <----------/
52 | |
53 | | |
54 | | |
55 | | | Pause: dec.RequestToStop
56 | | |
57 | | |
58 | | v
59 | |
60 -------------------------- Stopping
61
62 */
63
64 // Implementaton of the State pattern:
65 //
66 // PlayerState is an abstract state that has virtual methods for
67 // every possible event. Normally these methods do nothing.
68 //
69 // Concrete states (StatePaused, StatePlaying etc.) inherit from this
70 // PlayerState and implement the event handlers for the events expected
71 // to these states. If an event handler is omitted in a concrete state,
72 // the PlayerState method is called which usually means empty implementation
73 // and the event is ignored.
74
75 class MediaCodecPlayer;
76
77 class MediaCodecPlayerState {
78 public:
79 virtual const char* name() = 0;
80 virtual void EventRemoveVideoSurface(MediaCodecPlayer* player) {}
qinmin 2015/05/14 17:54:07 I would rename this to OnRemoveVideoSurface() or O
Tima Vaisburd 2015/05/15 00:12:40 Renamed to EventVideoSurfaceRemoved() to keep the
81 virtual void EventSetVideoSurface(MediaCodecPlayer* player) {}
82 virtual void EventStart(MediaCodecPlayer* player) {}
83 virtual void EventPause(MediaCodecPlayer* player) {}
84 virtual void EventSeekTo(MediaCodecPlayer* player,
85 base::TimeDelta timestamp) {}
86 virtual void EventDemuxerConfigsAvailable(MediaCodecPlayer* player,
87 const DemuxerConfigs& params);
88 virtual void EventDemuxerSeekDone(MediaCodecPlayer* player) {}
89 virtual void EventPrefetchDone(MediaCodecPlayer* player) {}
90 virtual void EventStopDone(MediaCodecPlayer* player) {}
91 virtual void EventStarvation(MediaCodecPlayer* player) {}
92 virtual void EventRelease(MediaCodecPlayer* player);
93 virtual void EventError(MediaCodecPlayer* player);
94 };
95
96 class StatePaused : public MediaCodecPlayerState {
97 DEFINE_INSTANCE(StatePaused);
98 public:
99 void EventStart(MediaCodecPlayer* player) override;
100 };
101
102 class StatePrefetching : public MediaCodecPlayerState {
103 DEFINE_INSTANCE(StatePrefetching);
104 public:
105 void EventPause(MediaCodecPlayer* player) override;
106 void EventPrefetchDone(MediaCodecPlayer* player) override;
107 };
108
109 class StateWaitingForConfig : public MediaCodecPlayerState {
110 DEFINE_INSTANCE(StateWaitingForConfig);
111 public:
112 void EventDemuxerConfigsAvailable(MediaCodecPlayer* player,
113 const DemuxerConfigs& params) override;
114 void EventPause(MediaCodecPlayer* player) override;
115 };
116
117 class StateWaitingForSurface : public MediaCodecPlayerState {
118 DEFINE_INSTANCE(StateWaitingForSurface);
119 public:
120 void EventSetVideoSurface(MediaCodecPlayer* player) override;
121 void EventPause(MediaCodecPlayer* player) override;
122 };
123
124 class StatePlaying : public MediaCodecPlayerState {
125 DEFINE_INSTANCE(StatePlaying);
126 public:
127 void EventPause(MediaCodecPlayer* player) override;
128 void EventStarvation(MediaCodecPlayer* player) override;
129 void EventStopDone(MediaCodecPlayer* player) override;
130 void EventError(MediaCodecPlayer* player) override;
131 };
132
133 class StateStopping : public MediaCodecPlayerState {
134 DEFINE_INSTANCE(StateStopping);
135 public:
136 void EventStart(MediaCodecPlayer* player) override;
137 void EventStopDone(MediaCodecPlayer* player) override;
138 };
139
140 class StateWaitingForSeek : public MediaCodecPlayerState {
141 DEFINE_INSTANCE(StateWaitingForSeek);
142 public:
143 };
144
145 class StateError : public MediaCodecPlayerState {
146 DEFINE_INSTANCE(StateError);
147 public:
148 };
149
150 } // namespace media
151
152 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698