| Index: media/base/pipeline_impl.h
|
| diff --git a/media/base/pipeline.h b/media/base/pipeline_impl.h
|
| similarity index 65%
|
| copy from media/base/pipeline.h
|
| copy to media/base/pipeline_impl.h
|
| index 5eae2e09e1f2ce80b76d90d977a3750fc4352479..a4a4757eb06f70d4e585fbf67481e529428eeb4d 100644
|
| --- a/media/base/pipeline.h
|
| +++ b/media/base/pipeline_impl.h
|
| @@ -1,9 +1,9 @@
|
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef MEDIA_BASE_PIPELINE_H_
|
| -#define MEDIA_BASE_PIPELINE_H_
|
| +#ifndef MEDIA_BASE_PIPELINE_IMPL_H_
|
| +#define MEDIA_BASE_PIPELINE_IMPL_H_
|
|
|
| #include "base/gtest_prod_util.h"
|
| #include "base/macros.h"
|
| @@ -11,21 +11,19 @@
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/synchronization/lock.h"
|
| #include "base/threading/thread_checker.h"
|
| -#include "base/time/default_tick_clock.h"
|
| +#include "base/time/time.h"
|
| #include "media/base/buffering_state.h"
|
| #include "media/base/cdm_context.h"
|
| #include "media/base/demuxer.h"
|
| #include "media/base/media_export.h"
|
| +#include "media/base/pipeline.h"
|
| #include "media/base/pipeline_status.h"
|
| #include "media/base/ranges.h"
|
| #include "media/base/serial_runner.h"
|
| #include "media/base/text_track.h"
|
| -#include "media/base/video_rotation.h"
|
| -#include "ui/gfx/geometry/size.h"
|
|
|
| namespace base {
|
| class SingleThreadTaskRunner;
|
| -class TimeDelta;
|
| }
|
|
|
| namespace media {
|
| @@ -33,23 +31,6 @@ namespace media {
|
| class MediaLog;
|
| class Renderer;
|
| class TextRenderer;
|
| -class TextTrackConfig;
|
| -class TimeDeltaInterpolator;
|
| -class VideoFrame;
|
| -
|
| -// Metadata describing a pipeline once it has been initialized.
|
| -struct PipelineMetadata {
|
| - PipelineMetadata()
|
| - : has_audio(false), has_video(false), video_rotation(VIDEO_ROTATION_0) {}
|
| -
|
| - bool has_audio;
|
| - bool has_video;
|
| - gfx::Size natural_size;
|
| - VideoRotation video_rotation;
|
| - base::Time timeline_offset;
|
| -};
|
| -
|
| -typedef base::Callback<void(PipelineMetadata)> PipelineMetadataCB;
|
|
|
| // Pipeline runs the media pipeline. Filters are created and called on the
|
| // task runner injected into this object. Pipeline works like a state
|
| @@ -91,35 +72,17 @@ typedef base::Callback<void(PipelineMetadata)> PipelineMetadataCB;
|
| // TODO(sandersd): It should be possible to pass through Suspended when going
|
| // from InitDemuxer to InitRenderer, thereby eliminating the Resuming state.
|
| // Some annoying differences between the two paths need to be removed first.
|
| -class MEDIA_EXPORT Pipeline : public DemuxerHost {
|
| +class MEDIA_EXPORT PipelineImpl : public Pipeline, public DemuxerHost {
|
| public:
|
| - // Used to paint VideoFrame.
|
| - typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB;
|
| -
|
| // Constructs a media pipeline that will execute on |task_runner|.
|
| - Pipeline(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
|
| - MediaLog* media_log);
|
| - ~Pipeline() override;
|
| -
|
| - // Build a pipeline to using the given |demuxer| and |renderer| to construct
|
| - // a filter chain, executing |seek_cb| when the initial seek has completed.
|
| - //
|
| - // The following permanent callbacks will be executed as follows up until
|
| - // Stop() has completed:
|
| - // |ended_cb| will be executed whenever the media reaches the end.
|
| - // |error_cb| will be executed whenever an error occurs but hasn't been
|
| - // reported already through another callback.
|
| - // |metadata_cb| will be executed when the content duration, container video
|
| - // size, start time, and whether the content has audio and/or
|
| - // video in supported formats are known.
|
| - // |buffering_state_cb| will be executed whenever there are changes in the
|
| - // overall buffering state of the pipeline.
|
| - // |duration_change_cb| optional callback that will be executed whenever the
|
| - // presentation duration changes.
|
| - // |add_text_track_cb| will be executed whenever a text track is added.
|
| - // |waiting_for_decryption_key_cb| will be executed whenever the key needed
|
| - // to decrypt the stream is not available.
|
| - // It is an error to call this method after the pipeline has already started.
|
| + PipelineImpl(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
|
| + MediaLog* media_log);
|
| + ~PipelineImpl() override;
|
| +
|
| + void SetErrorForTesting(PipelineStatus status);
|
| + bool HasWeakPtrsForTesting() const;
|
| +
|
| + // Pipeline implementation.
|
| void Start(Demuxer* demuxer,
|
| scoped_ptr<Renderer> renderer,
|
| const base::Closure& ended_cb,
|
| @@ -129,96 +92,30 @@ class MEDIA_EXPORT Pipeline : public DemuxerHost {
|
| const BufferingStateCB& buffering_state_cb,
|
| const base::Closure& duration_change_cb,
|
| const AddTextTrackCB& add_text_track_cb,
|
| - const base::Closure& waiting_for_decryption_key_cb);
|
| -
|
| - // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline
|
| - // teardown has completed.
|
| - //
|
| - // Stop() must complete before destroying the pipeline. It it permissible to
|
| - // call Stop() at any point during the lifetime of the pipeline.
|
| - //
|
| - // It is safe to delete the pipeline during the execution of |stop_cb|.
|
| - void Stop(const base::Closure& stop_cb);
|
| -
|
| - // Attempt to seek to the position specified by time. |seek_cb| will be
|
| - // executed when the all filters in the pipeline have processed the seek.
|
| - //
|
| - // Clients are expected to call GetMediaTime() to check whether the seek
|
| - // succeeded.
|
| - //
|
| - // It is an error to call this method if the pipeline has not started or
|
| - // is suspended.
|
| - void Seek(base::TimeDelta time, const PipelineStatusCB& seek_cb);
|
| -
|
| - // Returns true if the pipeline has been started via Start(). If IsRunning()
|
| - // returns true, it is expected that Stop() will be called before destroying
|
| - // the pipeline.
|
| - bool IsRunning() const;
|
| -
|
| - // Gets the current playback rate of the pipeline. When the pipeline is
|
| - // started, the playback rate will be 0.0. A rate of 1.0 indicates
|
| - // that the pipeline is rendering the media at the standard rate. Valid
|
| - // values for playback rate are >= 0.0.
|
| - double GetPlaybackRate() const;
|
| -
|
| - // Attempt to adjust the playback rate. Setting a playback rate of 0.0 pauses
|
| - // all rendering of the media. A rate of 1.0 indicates a normal playback
|
| - // rate. Values for the playback rate must be greater than or equal to 0.0.
|
| - //
|
| - // TODO(scherkus): What about maximum rate? Does HTML5 specify a max?
|
| - void SetPlaybackRate(double playback_rate);
|
| -
|
| - // Suspend the pipeline, discarding the current renderer.
|
| - //
|
| - // While suspended, GetMediaTime() returns the presentation timestamp of the
|
| - // last rendered frame.
|
| - //
|
| - // It is an error to call this method if the pipeline has not started or is
|
| - // seeking.
|
| - void Suspend(const PipelineStatusCB& suspend_cb);
|
| -
|
| - // Resume the pipeline with a new renderer, and initialize it with a seek.
|
| + const base::Closure& waiting_for_decryption_key_cb) override;
|
| + void Stop(const base::Closure& stop_cb) override;
|
| + void Seek(base::TimeDelta time, const PipelineStatusCB& seek_cb) override;
|
| + bool IsRunning() const override;
|
| + double GetPlaybackRate() const override;
|
| + void SetPlaybackRate(double playback_rate) override;
|
| + void Suspend(const PipelineStatusCB& suspend_cb) override;
|
| void Resume(scoped_ptr<Renderer> renderer,
|
| base::TimeDelta timestamp,
|
| - const PipelineStatusCB& seek_cb);
|
| -
|
| - // Gets the current volume setting being used by the audio renderer. When
|
| - // the pipeline is started, this value will be 1.0f. Valid values range
|
| - // from 0.0f to 1.0f.
|
| - float GetVolume() const;
|
| -
|
| - // Attempt to set the volume of the audio renderer. Valid values for volume
|
| - // range from 0.0f (muted) to 1.0f (full volume). This value affects all
|
| - // channels proportionately for multi-channel audio streams.
|
| - void SetVolume(float volume);
|
| -
|
| - // Returns the current media playback time, which progresses from 0 until
|
| - // GetMediaDuration().
|
| - base::TimeDelta GetMediaTime() const;
|
| -
|
| - // Get approximate time ranges of buffered media.
|
| - Ranges<base::TimeDelta> GetBufferedTimeRanges() const;
|
| -
|
| - // Get the duration of the media in microseconds. If the duration has not
|
| - // been determined yet, then returns 0.
|
| - base::TimeDelta GetMediaDuration() const;
|
| -
|
| - // Return true if loading progress has been made since the last time this
|
| - // method was called.
|
| - bool DidLoadingProgress();
|
| -
|
| - // Gets the current pipeline statistics.
|
| - PipelineStatistics GetStatistics() const;
|
| -
|
| - void SetCdm(CdmContext* cdm_context, const CdmAttachedCB& cdm_attached_cb);
|
| -
|
| - void SetErrorForTesting(PipelineStatus status);
|
| - bool HasWeakPtrsForTesting() const;
|
| + const PipelineStatusCB& seek_cb) override;
|
| + float GetVolume() const override;
|
| + void SetVolume(float volume) override;
|
| + base::TimeDelta GetMediaTime() const override;
|
| + Ranges<base::TimeDelta> GetBufferedTimeRanges() const override;
|
| + base::TimeDelta GetMediaDuration() const override;
|
| + bool DidLoadingProgress() override;
|
| + PipelineStatistics GetStatistics() const override;
|
| + void SetCdm(CdmContext* cdm_context,
|
| + const CdmAttachedCB& cdm_attached_cb) override;
|
|
|
| private:
|
| - FRIEND_TEST_ALL_PREFIXES(PipelineTest, GetBufferedTimeRanges);
|
| - FRIEND_TEST_ALL_PREFIXES(PipelineTest, EndedCallback);
|
| - FRIEND_TEST_ALL_PREFIXES(PipelineTest, AudioStreamShorterThanVideo);
|
| + FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTimeRanges);
|
| + FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, EndedCallback);
|
| + FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, AudioStreamShorterThanVideo);
|
| friend class MediaLog;
|
|
|
| // Pipeline states, as described above.
|
| @@ -429,11 +326,11 @@ class MEDIA_EXPORT Pipeline : public DemuxerHost {
|
| base::ThreadChecker thread_checker_;
|
|
|
| // NOTE: Weak pointers must be invalidated before all other member variables.
|
| - base::WeakPtrFactory<Pipeline> weak_factory_;
|
| + base::WeakPtrFactory<PipelineImpl> weak_factory_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(Pipeline);
|
| + DISALLOW_COPY_AND_ASSIGN(PipelineImpl);
|
| };
|
|
|
| } // namespace media
|
|
|
| -#endif // MEDIA_BASE_PIPELINE_H_
|
| +#endif // MEDIA_BASE_PIPELINE_IMPL_H_
|
|
|