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

Side by Side Diff: chromecast/public/media/media_component_device.h

Issue 1257013003: Load CMA backend from shared library (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Commenting public APIs reverted VideoClient ownership Created 5 years, 4 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 2014 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 CHROMECAST_PUBLIC_MEDIA_MEDIA_COMPONENT_DEVICE_H_
6 #define CHROMECAST_PUBLIC_MEDIA_MEDIA_COMPONENT_DEVICE_H_
7
8 #include <stdint.h>
9 #include <string>
10
11 #include "cast_key_system.h"
12
13 namespace chromecast {
14 namespace media {
15 class CastDecoderBuffer;
16
17 // Common base interface for both platform-specific audio and video pipeline
18 // backends. Both follow this state machine:
19 // -------------- kRunning <---
byungchul 2015/07/29 20:32:23 Use + at the point the line is changed. ----+
halliwell 2015/07/29 22:39:27 Done.
20 // | ^ |
21 // v | |
22 // kUninitialized <--> kIdle -------------- |
23 // ^ | |
24 // | v |
25 // -------------- kPaused <----
26 // {any state} --> kError
27 // kError --> kUninitialized
28 //
29 // Notes:
30 // - Hardware resources should be acquired when transitioning from the
31 // |kUninitialized| state to the |kIdle| state.
32 // - Buffers will be pushed only in the kRunning or kPaused states.
33 // - The end of stream is signaled through a special buffer.
34 // Once the end of stream buffer is fed, no other buffer
35 // will be fed until the FSM goes through the kIdle state again.
36 // - In both kPaused and kRunning states, frames can be fed.
37 // However, frames are possibly rendered only in the kRunning state.
38 // - In the kRunning state, frames are rendered according to the clock rate.
39 // - All the hardware resources must be released in the |kError| state.
40 class MediaComponentDevice {
41 public:
42 enum State {
43 kStateUninitialized,
44 kStateIdle,
45 kStateRunning,
46 kStatePaused,
47 kStateError,
48 };
49
50 enum FrameStatus {
51 kFrameSuccess,
52 kFrameFailed,
53 kFramePending,
54 };
55
56 // Interface for receiving status when PushFrame has completed.
57 class FrameStatusCB {
58 public:
59 virtual ~FrameStatusCB() {}
60 virtual void Run(FrameStatus status) = 0;
61 };
62
63 // Client callbacks interface
64 class Client {
65 public:
66 virtual ~Client() {}
67 virtual void OnEndOfStream() = 0;
68 };
69
70 // The statistics are computed since the media component left the idle state.
71 // For video, a sample is defined as a frame.
72 struct Statistics {
73 uint64_t decoded_bytes;
74 uint64_t decoded_samples;
75 uint64_t dropped_samples;
76 };
77
78 // Info on pipeline latency: amount of data in pipeline not rendered yet,
79 // and timestamp of system clock (must be CLOCK_MONOTONIC) at which delay
80 // measurement was taken. Both times in microseconds.
81 struct RenderingDelay {
82 RenderingDelay() : delay(INT64_MIN), timestamp(INT64_MIN) {}
83 RenderingDelay(int64_t delay_in, int64_t timestamp_in)
84 : delay(delay_in), timestamp(timestamp_in) {}
85 int64_t delay;
86 int64_t timestamp;
87 };
88
89 virtual ~MediaComponentDevice() {}
90
91 // Registers |client| as the media event handler. Implementation
92 // takes ownership of |client| and call OnEndOfStream when an end-of-stream
93 // buffer is processed.
94 virtual void SetClient(Client* client) = 0;
95
96 // Changes the state and performs any necessary transitions.
97 // Returns true when successful.
98 virtual bool SetState(State new_state) = 0;
99
100 // Returns the current state of the media component.
101 virtual State GetState() const = 0;
102
103 // Sets the time where rendering should start.
104 // Return true when successful.
105 // Will only be invoked in state kStateIdle.
106 virtual bool SetStartPts(int64_t microseconds) = 0;
107
108 // Pushes a frame. If the implementation cannot push the buffer
109 // now, it must store the buffer, return |kFramePending| and execute the push
110 // at a later time when it becomes possible to do so. The implementation must
111 // then invoke |completion_cb|. Pushing a pending frame should be aborted if
112 // the state returns to kStateIdle, and |completion_cb| need not be invoked.
113 // If |kFramePending| is returned, the pipeline will stop pushing any further
114 // buffers until the |completion_cb| is invoked.
115 // |buffer| is owned by the implementation and must be freed once the data is
116 // used.
117 // |completion_cb| is owned by the implementation and must be freed, even in
byungchul 2015/07/29 20:32:23 s/freed/deleted or destroyed?
halliwell 2015/07/29 22:39:27 Done.
118 // cases where it is not called. |completion_cb| should be only be invoked
119 // to indicate completion of a pending buffer push - not for the immediate
120 // |kFrameSuccess| return case.
121 virtual FrameStatus PushFrame(CastKeySystem key_system,
122 CastDecoderBuffer* buffer,
123 FrameStatusCB* completion_cb) = 0;
124
125 // Returns the pipeline latency: i.e. the amount of data
126 // in the pipeline that have not been rendered yet, in microseconds.
127 // Returns delay = INT64_MIN if the latency is not available.
128 virtual RenderingDelay GetRenderingDelay() const = 0;
129
130 // Returns the playback statistics since the last transition from idle state.
131 // Returns true when successful.
132 // Is only invoked in state kStateRunning.
133 virtual bool GetStatistics(Statistics* stats) const = 0;
134 };
135
136 } // namespace media
137 } // namespace chromecast
138
139 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_COMPONENT_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698