-
Notifications
You must be signed in to change notification settings - Fork 0
/
mediaplayer_impl.h
127 lines (104 loc) · 4.24 KB
/
mediaplayer_impl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
//
#ifndef CHROMIUM_MEDIA_LIB_MEDIAPLAYER_IMPL_H_
#define CHROMIUM_MEDIA_LIB_MEDIAPLAYER_IMPL_H_
#include <memory>
#include <vector>
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "chromium_media_lib/audiosourceprovider_impl.h"
#include "chromium_media_lib/file_data_source.h"
#include "chromium_media_lib/mediaplayer_params.h"
#include "chromium_media_lib/resource_data_source.h"
#include "chromium_media_lib/video_renderer_sink_impl.h"
#include "media/base/media_observer.h"
#include "media/base/media_tracks.h"
#include "media/base/pipeline_impl.h"
#include "media/base/renderer_factory.h"
#include "media/filters/pipeline_controller.h"
#include "url/gurl.h"
namespace media {
class MEDIA_EXPORT MediaPlayerImpl
: public Pipeline::Client,
public MediaObserverClient,
public base::SupportsWeakPtr<MediaPlayerImpl> {
public:
MediaPlayerImpl(MediaPlayerParams& params);
~MediaPlayerImpl() override;
// Playback controls.
void Load(GURL url);
void Load(const base::FilePath& path);
void Play();
void Pause();
bool SupportsSave() const;
void Seek(double seconds);
void SetRate(double rate);
void SetVolume(double volume);
base::TimeDelta GetPipelineMediaDuration() const;
void SetVideoRendererSinkClient(VideoRendererSinkClient* client);
private:
// Pipeline::Client overrides.
void OnError(PipelineStatus status) override;
void OnEnded() override;
void OnMetadata(PipelineMetadata metadata) override;
void OnBufferingStateChange(BufferingState state) override;
void OnDurationChange() override;
void OnAddTextTrack(const TextTrackConfig& config,
const AddTextTrackDoneCB& done_cb) override;
void OnWaitingForDecryptionKey() override;
void OnAudioConfigChange(const AudioDecoderConfig& config) override;
void OnVideoConfigChange(const VideoDecoderConfig& config) override;
void OnVideoNaturalSizeChange(const gfx::Size& size) override;
void OnVideoOpacityChange(bool opaque) override;
void OnVideoAverageKeyframeDistanceUpdate() override;
// MediaObserverClient implementation.
void SwitchToRemoteRenderer(
const std::string& remote_device_friendly_name) override;
void SwitchToLocalRenderer() override;
void ActivateViewportIntersectionMonitoring(bool activate) override;
void UpdateRemotePlaybackCompatibility(bool is_compatible) override;
size_t AudioDecodedByteCount() const override;
size_t VideoDecodedByteCount() const override;
void DataSourceInitialized(bool success);
void StartPipeline();
void OnPipelineSeeked(bool time_updated);
void OnPipelineSuspended();
void OnBeforePipelineResume();
void OnPipelineResumed();
void OnDemuxerOpened();
std::unique_ptr<Renderer> CreateRenderer();
void DoSeek(base::TimeDelta time, bool time_updated);
void OnEncryptedMediaInitData(EmeInitDataType init_data_type,
const std::vector<uint8_t>& init_data);
void OnFFmpegMediaTracksUpdated(std::unique_ptr<MediaTracks> tracks);
PipelineStatistics GetPipelineStatistics() const;
private:
const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
scoped_refptr<base::TaskRunner> worker_task_runner_;
std::unique_ptr<MediaLog> media_log_;
scoped_refptr<AudioSourceProviderImpl> audio_source_provider_;
int owner_id_;
PipelineMetadata pipeline_metadata_;
double playback_rate_;
bool paused_;
base::TimeDelta paused_time_;
bool seeking_;
base::TimeDelta seek_time_;
bool ended_;
double volume_;
std::unique_ptr<VideoRendererSinkImpl> video_renderer_sink_;
// |pipeline_controller_| owns an instance of Pipeline.
PipelineController pipeline_controller_;
GURL loaded_url_;
std::unique_ptr<RendererFactory> renderer_factory_;
std::unique_ptr<FileDataSource> data_source_;
std::unique_ptr<ResourceDataSource> resource_source_;
std::unique_ptr<Demuxer> demuxer_;
DISALLOW_COPY_AND_ASSIGN(MediaPlayerImpl);
};
} // namespace media
#endif // CHROMIUM_MEDIA_LIB_MEDIAPLAYER_IMPL_H_