Index: chromecast/public/media/media_component_device.h |
diff --git a/chromecast/media/cma/backend/media_component_device.h b/chromecast/public/media/media_component_device.h |
similarity index 61% |
rename from chromecast/media/cma/backend/media_component_device.h |
rename to chromecast/public/media/media_component_device.h |
index fd62d8dfa2ff6b1b4a779ceae1c6014a7b3a163a..b3003c943a62d2850423e665be5b79a023caf61b 100644 |
--- a/chromecast/media/cma/backend/media_component_device.h |
+++ b/chromecast/public/media/media_component_device.h |
@@ -2,22 +2,17 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_COMPONENT_DEVICE_H_ |
-#define CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_COMPONENT_DEVICE_H_ |
+#ifndef CHROMECAST_PUBLIC_MEDIA_MEDIA_COMPONENT_DEVICE_H_ |
+#define CHROMECAST_PUBLIC_MEDIA_MEDIA_COMPONENT_DEVICE_H_ |
+#include <stdint.h> |
#include <string> |
-#include "base/basictypes.h" |
-#include "base/callback.h" |
-#include "base/macros.h" |
-#include "base/memory/ref_counted.h" |
-#include "base/threading/non_thread_safe.h" |
-#include "base/time/time.h" |
+#include "cast_key_system.h" |
namespace chromecast { |
namespace media { |
-class DecoderBufferBase; |
-class DecryptContext; |
+class CastDecoderBuffer; |
// MediaComponentDevice - |
// |
@@ -44,8 +39,7 @@ class DecryptContext; |
// - In the kRunning state, frames are rendered according to the clock rate. |
// - All the hardware resources must be released in the |kError| state. |
// |
-class MediaComponentDevice |
- : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
+class MediaComponentDevice { |
public: |
enum State { |
kStateUninitialized, |
@@ -60,35 +54,45 @@ class MediaComponentDevice |
kFrameFailed, |
kFramePending, |
}; |
- typedef base::Callback<void(FrameStatus)> FrameStatusCB; |
- struct Client { |
- Client(); |
- ~Client(); |
+ // Interface for receiving status when PushFrame has completed. |
+ class FrameStatusCB { |
+ public: |
+ virtual ~FrameStatusCB() {} |
+ virtual void Run(FrameStatus status) = 0; |
+ }; |
- // Invoked when playback reaches the end of stream. |
- base::Closure eos_cb; |
+ // Client callbacks interface |
+ class Client { |
+ public: |
+ virtual ~Client() {} |
+ virtual void OnEndOfStream() = 0; |
}; |
// The statistics are computed since the media component left the idle state. |
// For video, a sample is defined as a frame. |
struct Statistics { |
- uint64 decoded_bytes; |
- uint64 decoded_samples; |
- uint64 dropped_samples; |
+ uint64_t decoded_bytes; |
+ uint64_t decoded_samples; |
+ uint64_t dropped_samples; |
}; |
- // Returns whether or not transitioning from |state1| to |state2| is valid. |
- static bool IsValidStateTransition(State state1, State state2); |
- |
- // Returns string representation of state (for logging) |
- static std::string StateToString(const State& state); |
+ // Info on pipeline latency: amount of data in pipeline not rendered yet, |
+ // and timestamp of system clock (must be CLOCK_MONOTONIC) at which delay |
+ // measurement was taken. Both times in microseconds. |
+ struct RenderingDelay { |
+ RenderingDelay() : delay(INT64_MIN), timestamp(INT64_MIN) {} |
+ RenderingDelay(int64_t delay_in, int64_t timestamp_in) |
+ : delay(delay_in), timestamp(timestamp_in) {} |
+ int64_t delay; |
+ int64_t timestamp; |
+ }; |
- MediaComponentDevice(); |
- virtual ~MediaComponentDevice(); |
+ virtual ~MediaComponentDevice() {} |
- // Register |client| as the media event handler. |
- virtual void SetClient(const Client& client) = 0; |
+ // Register |client| as the media event handler. Implementation |
+ // takes ownership of |client|. |
+ virtual void SetClient(Client* client) = 0; |
// Changes the state and performs any necessary transitions. |
// Returns true when successful. |
@@ -100,38 +104,31 @@ class MediaComponentDevice |
// Sets the time where rendering should start. |
// Return true when successful. |
// Can only be invoked in state kStateIdle. |
- virtual bool SetStartPts(base::TimeDelta time) = 0; |
+ virtual bool SetStartPts(int64_t microseconds) = 0; |
// Pushes a frame. |
+ // The implementation takes ownership of |buffer|. |
// |completion_cb| is only invoked if the returned value is |kFramePending|. |
// In this specific case, no additional frame can be pushed before |
// |completion_cb| is invoked. |
// Note: |completion_cb| cannot be invoked with |kFramePending|. |
// Note: pushing the pending frame should be aborted when the state goes back |
// to kStateIdle. |completion_cb| is not invoked in that case. |
- virtual FrameStatus PushFrame( |
- const scoped_refptr<DecryptContext>& decrypt_context, |
- const scoped_refptr<DecoderBufferBase>& buffer, |
- const FrameStatusCB& completion_cb) = 0; |
- |
- // Returns the rendering time of the latest rendered sample. |
- // Can be invoked only in states kStateRunning or kStatePaused. |
- // Returns |kNoTimestamp()| if the playback time cannot be retrieved. |
- virtual base::TimeDelta GetRenderingTime() const = 0; |
+ // Implementation must take ownership of completion_cb and free after calling. |
+ virtual FrameStatus PushFrame(CastKeySystem key_system, |
+ CastDecoderBuffer* buffer, |
+ FrameStatusCB* completion_cb) = 0; |
// Returns the pipeline latency: i.e. the amount of data |
- // in the pipeline that have not been rendered yet. |
- // Returns |kNoTimestamp()| if the latency is not available. |
- virtual base::TimeDelta GetRenderingDelay() const = 0; |
+ // in the pipeline that have not been rendered yet, in microseconds. |
+ // Returns delay = INT64_MIN if the latency is not available. |
+ virtual RenderingDelay GetRenderingDelay() const = 0; |
// Returns the playback statistics. Statistics are computed since the media |
// component left the idle state. |
// Returns true when successful. |
// Can only be invoked in state kStateRunning. |
virtual bool GetStatistics(Statistics* stats) const = 0; |
- |
- private: |
- DISALLOW_COPY_AND_ASSIGN(MediaComponentDevice); |
}; |
} // namespace media |