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.
5 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_COMPONENT_DEVICE_DEFAULT_H_
6 #define CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_COMPONENT_DEVICE_DEFAULT_H_
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread_checker.h"
14 #include "chromecast/public/media/media_clock_device.h"
15 #include "chromecast/public/media/media_component_device.h"
17 namespace chromecast
{
21 struct MediaPipelineDeviceParams
;
23 class MediaComponentDeviceDefault
: public MediaComponentDevice
{
25 MediaComponentDeviceDefault(const MediaPipelineDeviceParams
& params
,
26 MediaClockDevice
* media_clock_device
);
27 ~MediaComponentDeviceDefault() override
;
29 // MediaComponentDevice implementation.
30 void SetClient(Client
* client
) override
;
31 State
GetState() const override
;
32 bool SetState(State new_state
) override
;
33 bool SetStartPts(int64_t time_microseconds
) override
;
34 FrameStatus
PushFrame(DecryptContext
* decrypt_context
,
35 CastDecoderBuffer
* buffer
,
36 FrameStatusCB
* completion_cb
) override
;
37 RenderingDelay
GetRenderingDelay() const override
;
38 bool GetStatistics(Statistics
* stats
) const override
;
41 struct DefaultDecoderBuffer
{
42 DefaultDecoderBuffer();
43 ~DefaultDecoderBuffer();
48 // Presentation timestamp.
54 TaskRunner
* task_runner_
;
55 MediaClockDevice
* const media_clock_device_
;
56 scoped_ptr
<Client
> client_
;
60 // Indicate whether the end of stream has been received.
63 // Media time of the last rendered audio sample.
64 base::TimeDelta rendering_time_
;
66 // Frame decoded/rendered since the pipeline left the idle state.
67 uint64 decoded_frame_count_
;
68 uint64 decoded_byte_count_
;
70 // List of frames not rendered yet.
71 std::list
<DefaultDecoderBuffer
> frames_
;
73 // Indicate whether there is a scheduled rendering task.
74 bool scheduled_rendering_task_
;
77 scoped_ptr
<CastDecoderBuffer
> pending_buffer_
;
78 scoped_ptr
<FrameStatusCB
> frame_pushed_cb_
;
80 base::ThreadChecker thread_checker_
;
82 base::WeakPtr
<MediaComponentDeviceDefault
> weak_this_
;
83 base::WeakPtrFactory
<MediaComponentDeviceDefault
> weak_factory_
;
85 DISALLOW_COPY_AND_ASSIGN(MediaComponentDeviceDefault
);
89 } // namespace chromecast
91 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_COMPONENT_DEVICE_DEFAULT_H_