blob: 853a21a2a7557de19768dc430e19613560c52dee [file] [log] [blame]
[email protected]a4dae8e2012-03-15 23:35:311// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]a2b5c472011-09-13 20:24:102// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef MEDIA_BASE_DEMUXER_H_
6#define MEDIA_BASE_DEMUXER_H_
7
[email protected]322d22c2013-08-26 18:50:418#include <vector>
9
[email protected]7e72e7b2013-06-28 05:40:1010#include "base/time/time.h"
[email protected]236119c2011-12-16 17:14:2511#include "media/base/data_source.h"
[email protected]a2b5c472011-09-13 20:24:1012#include "media/base/demuxer_stream.h"
13#include "media/base/media_export.h"
[email protected]a2b5c472011-09-13 20:24:1014#include "media/base/pipeline_status.h"
15
16namespace media {
17
[email protected]236119c2011-12-16 17:14:2518class MEDIA_EXPORT DemuxerHost : public DataSourceHost {
19 public:
[email protected]60bf9222012-05-26 00:31:3420 // Sets the duration of the media in microseconds.
21 // Duration may be kInfiniteDuration() if the duration is not known.
[email protected]236119c2011-12-16 17:14:2522 virtual void SetDuration(base::TimeDelta duration) = 0;
23
[email protected]236119c2011-12-16 17:14:2524 // Stops execution of the pipeline due to a fatal error. Do not call this
25 // method with PIPELINE_OK.
26 virtual void OnDemuxerError(PipelineStatus error) = 0;
[email protected]512d03f2012-06-26 01:06:0627
28 protected:
29 virtual ~DemuxerHost();
[email protected]236119c2011-12-16 17:14:2530};
[email protected]a2b5c472011-09-13 20:24:1031
[email protected]f5443ef72013-04-22 04:03:3832class MEDIA_EXPORT Demuxer {
[email protected]a2b5c472011-09-13 20:24:1033 public:
[email protected]322d22c2013-08-26 18:50:4134 // A new potentially encrypted stream has been parsed.
35 // First parameter - The type of initialization data.
36 // Second parameter - The initialization data associated with the stream.
37 typedef base::Callback<void(const std::string& type,
38 const std::vector<uint8>& init_data)> NeedKeyCB;
39
[email protected]236119c2011-12-16 17:14:2540 Demuxer();
[email protected]f5443ef72013-04-22 04:03:3841 virtual ~Demuxer();
[email protected]236119c2011-12-16 17:14:2542
[email protected]9bfe9b82012-04-02 17:56:2743 // Completes initialization of the demuxer.
44 //
[email protected]d09ef252012-04-05 04:31:3045 // The demuxer does not own |host| as it is guaranteed to outlive the
46 // lifetime of the demuxer. Don't delete it!
47 virtual void Initialize(DemuxerHost* host,
48 const PipelineStatusCB& status_cb) = 0;
[email protected]9bfe9b82012-04-02 17:56:2749
[email protected]a2b5c472011-09-13 20:24:1050 // The pipeline playback rate has been changed. Demuxers may implement this
51 // method if they need to respond to this call.
52 virtual void SetPlaybackRate(float playback_rate);
53
54 // Carry out any actions required to seek to the given time, executing the
55 // callback upon completion.
[email protected]a4dae8e2012-03-15 23:35:3156 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& status_cb);
[email protected]a2b5c472011-09-13 20:24:1057
[email protected]8b754552013-08-22 00:31:0558 // Starts stopping this demuxer, executing the callback upon completion.
59 //
60 // After the callback completes the demuxer may be destroyed. It is illegal to
61 // call any method (including Stop()) after a demuxer has stopped.
[email protected]adabb6272011-09-29 22:36:3862 virtual void Stop(const base::Closure& callback);
[email protected]a2b5c472011-09-13 20:24:1063
64 // This method is called from the pipeline when the audio renderer
65 // is disabled. Demuxers can ignore the notification if they do not
66 // need to react to this event.
67 //
68 // TODO(acolwell): Change to generic DisableStream(DemuxerStream::Type).
[email protected]34811ef2013-04-25 08:51:4769 // TODO(scherkus): this might not be needed http://crbug.com/234708
[email protected]a2b5c472011-09-13 20:24:1070 virtual void OnAudioRendererDisabled();
71
72 // Returns the given stream type, or NULL if that type is not present.
[email protected]34811ef2013-04-25 08:51:4773 virtual DemuxerStream* GetStream(DemuxerStream::Type type) = 0;
[email protected]a2b5c472011-09-13 20:24:1074
[email protected]a2b5c472011-09-13 20:24:1075 // Returns the starting time for the media file.
76 virtual base::TimeDelta GetStartTime() const = 0;
77
[email protected]a2b5c472011-09-13 20:24:1078 private:
[email protected]a2b5c472011-09-13 20:24:1079 DISALLOW_COPY_AND_ASSIGN(Demuxer);
80};
81
82} // namespace media
83
84#endif // MEDIA_BASE_DEMUXER_H_