Evict resources from resource pool after timeout
[chromium-blink-merge.git] / media / base / demuxer.h
blob91f389d0175810f21c70b0985ada386855adec20
1 // Copyright (c) 2012 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 MEDIA_BASE_DEMUXER_H_
6 #define MEDIA_BASE_DEMUXER_H_
8 #include <vector>
10 #include "base/time/time.h"
11 #include "media/base/data_source.h"
12 #include "media/base/demuxer_stream.h"
13 #include "media/base/demuxer_stream_provider.h"
14 #include "media/base/eme_constants.h"
15 #include "media/base/media_export.h"
16 #include "media/base/pipeline_status.h"
18 namespace media {
20 class TextTrackConfig;
22 class MEDIA_EXPORT DemuxerHost {
23 public:
24 // Notify the host that time range [start,end] has been buffered.
25 virtual void AddBufferedTimeRange(base::TimeDelta start,
26 base::TimeDelta end) = 0;
28 // Sets the duration of the media in microseconds.
29 // Duration may be kInfiniteDuration() if the duration is not known.
30 virtual void SetDuration(base::TimeDelta duration) = 0;
32 // Stops execution of the pipeline due to a fatal error. Do not call this
33 // method with PIPELINE_OK.
34 virtual void OnDemuxerError(PipelineStatus error) = 0;
36 // Add |text_stream| to the collection managed by the text renderer.
37 virtual void AddTextStream(DemuxerStream* text_stream,
38 const TextTrackConfig& config) = 0;
40 // Remove |text_stream| from the presentation.
41 virtual void RemoveTextStream(DemuxerStream* text_stream) = 0;
43 protected:
44 virtual ~DemuxerHost();
47 class MEDIA_EXPORT Demuxer : public DemuxerStreamProvider {
48 public:
49 // A new potentially encrypted stream has been parsed.
50 // First parameter - The type of initialization data.
51 // Second parameter - The initialization data associated with the stream.
52 typedef base::Callback<void(EmeInitDataType type,
53 const std::vector<uint8>& init_data)>
54 EncryptedMediaInitDataCB;
56 Demuxer();
57 ~Demuxer() override;
59 // Returns the name of the demuxer for logging purpose.
60 virtual std::string GetDisplayName() const = 0;
62 // Completes initialization of the demuxer.
64 // The demuxer does not own |host| as it is guaranteed to outlive the
65 // lifetime of the demuxer. Don't delete it! |status_cb| must only be run
66 // after this method has returned.
67 virtual void Initialize(DemuxerHost* host,
68 const PipelineStatusCB& status_cb,
69 bool enable_text_tracks) = 0;
71 // Carry out any actions required to seek to the given time, executing the
72 // callback upon completion.
73 virtual void Seek(base::TimeDelta time,
74 const PipelineStatusCB& status_cb) = 0;
76 // Stops this demuxer.
78 // After this call the demuxer may be destroyed. It is illegal to call any
79 // method (including Stop()) after a demuxer has stopped.
80 virtual void Stop() = 0;
82 // Returns the starting time for the media file; it's always positive.
83 virtual base::TimeDelta GetStartTime() const = 0;
85 // Returns Time represented by presentation timestamp 0.
86 // If the timstamps are not associated with a Time, then
87 // a null Time is returned.
88 virtual base::Time GetTimelineOffset() const = 0;
90 private:
91 DISALLOW_COPY_AND_ASSIGN(Demuxer);
94 } // namespace media
96 #endif // MEDIA_BASE_DEMUXER_H_