Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chromecast / media / cma / backend / media_component_device_default.h
blobd6dc7eaa205671c0fb87d10395946a80604703a4
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_
8 #include <list>
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 {
18 class TaskRunner;
20 namespace media {
21 struct MediaPipelineDeviceParams;
23 class MediaComponentDeviceDefault : public MediaComponentDevice {
24 public:
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;
40 private:
41 struct DefaultDecoderBuffer {
42 DefaultDecoderBuffer();
43 ~DefaultDecoderBuffer();
45 // Buffer size.
46 size_t size;
48 // Presentation timestamp.
49 base::TimeDelta pts;
52 void RenderTask();
54 TaskRunner* task_runner_;
55 MediaClockDevice* const media_clock_device_;
56 scoped_ptr<Client> client_;
58 State state_;
60 // Indicate whether the end of stream has been received.
61 bool is_eos_;
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_;
76 // Pending frame.
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);
88 } // namespace media
89 } // namespace chromecast
91 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_COMPONENT_DEVICE_DEFAULT_H_