2014-04-01 01:34:59 +00:00
|
|
|
// Copyright 2014 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.
|
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
#ifndef MEDIA_FORMATS_MP2T_MP2T_MEDIA_PARSER_H_
|
|
|
|
#define MEDIA_FORMATS_MP2T_MP2T_MEDIA_PARSER_H_
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
#include <deque>
|
2014-04-01 01:34:59 +00:00
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include "base/memory/ref_counted.h"
|
|
|
|
#include "base/memory/scoped_ptr.h"
|
|
|
|
#include "media/base/byte_queue.h"
|
2014-04-10 19:57:10 +00:00
|
|
|
#include "media/base/media_parser.h"
|
|
|
|
#include "media/base/stream_info.h"
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
2014-04-01 01:34:59 +00:00
|
|
|
namespace media {
|
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
class MediaSample;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
namespace mp2t {
|
|
|
|
|
|
|
|
class PidState;
|
2014-04-10 19:57:10 +00:00
|
|
|
class TsPacket;
|
|
|
|
class TsSection;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
typedef std::deque<scoped_refptr<MediaSample> > SampleQueue;
|
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
class Mp2tMediaParser : public MediaParser {
|
2014-04-01 01:34:59 +00:00
|
|
|
public:
|
2014-07-02 19:21:56 +00:00
|
|
|
Mp2tMediaParser();
|
2014-04-16 23:22:31 +00:00
|
|
|
virtual ~Mp2tMediaParser();
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
// MediaParser implementation overrides.
|
2014-04-01 01:34:59 +00:00
|
|
|
virtual void Init(const InitCB& init_cb,
|
2014-04-10 19:57:10 +00:00
|
|
|
const NewSampleCB& new_sample_cb,
|
2014-08-25 22:51:19 +00:00
|
|
|
KeySource* decryption_key_source) OVERRIDE;
|
2014-04-10 19:57:10 +00:00
|
|
|
|
2014-04-01 01:34:59 +00:00
|
|
|
virtual void Flush() OVERRIDE;
|
2014-04-10 19:57:10 +00:00
|
|
|
|
2014-04-01 01:34:59 +00:00
|
|
|
virtual bool Parse(const uint8* buf, int size) OVERRIDE;
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef std::map<int, PidState*> PidMap;
|
|
|
|
|
|
|
|
// Callback invoked to register a Program Map Table.
|
|
|
|
// Note: Does nothing if the PID is already registered.
|
|
|
|
void RegisterPmt(int program_number, int pmt_pid);
|
|
|
|
|
|
|
|
// Callback invoked to register a PES pid.
|
2014-04-10 19:57:10 +00:00
|
|
|
// Possible values for |media_type| are defined in:
|
|
|
|
// ISO-13818.1 / ITU H.222 Table 2.34 "Media type assignments".
|
2014-04-01 01:34:59 +00:00
|
|
|
// |pes_pid| is part of the Program Map Table refered by |pmt_pid|.
|
2014-04-10 19:57:10 +00:00
|
|
|
void RegisterPes(int pmt_pid, int pes_pid, int media_type);
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// Callback invoked each time the audio/video decoder configuration is
|
|
|
|
// changed.
|
2014-04-10 19:57:10 +00:00
|
|
|
void OnNewStreamInfo(scoped_refptr<StreamInfo>& new_stream_info);
|
|
|
|
|
|
|
|
// Callback invoked by the ES media parser
|
|
|
|
// to emit a new audio/video access unit.
|
|
|
|
void OnEmitSample(uint32 pes_pid, scoped_refptr<MediaSample>& new_sample);
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// Invoke the initialization callback if needed.
|
|
|
|
bool FinishInitializationIfNeeded();
|
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
bool EmitRemainingSamples();
|
|
|
|
|
|
|
|
/// Set the value of the "SBR in mime-type" flag which leads to sample rate
|
|
|
|
/// doubling. Default value is false.
|
|
|
|
void set_sbr_in_mime_type(bool sbr_in_mimetype) {
|
|
|
|
sbr_in_mimetype_ = sbr_in_mimetype; }
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// List of callbacks.
|
|
|
|
InitCB init_cb_;
|
2014-04-10 19:57:10 +00:00
|
|
|
NewSampleCB new_sample_cb_;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
bool sbr_in_mimetype_;
|
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
// Bytes of the TS media.
|
2014-04-01 01:34:59 +00:00
|
|
|
ByteQueue ts_byte_queue_;
|
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
// List of PIDs and their states.
|
2014-04-01 01:34:59 +00:00
|
|
|
PidMap pids_;
|
|
|
|
|
|
|
|
// Whether |init_cb_| has been invoked.
|
|
|
|
bool is_initialized_;
|
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(Mp2tMediaParser);
|
2014-04-01 01:34:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp2t
|
|
|
|
} // namespace media
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
#endif
|