#ifndef MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_
#define MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_
#include <list>
#include <utility>
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "media/base/media_export.h"
#include "media/base/video_decoder_config.h"
#include "media/formats/mp2t/es_parser.h"
namespace media {
class H264Parser;
struct H264SPS;
class OffsetByteQueue;
}
namespace media {
namespace mp2t {
class MEDIA_EXPORT EsParserH264 : NON_EXPORTED_BASE(public EsParser) {
public:
typedef base::Callback<void(const VideoDecoderConfig&)> NewVideoConfigCB;
EsParserH264(const NewVideoConfigCB& new_video_config_cb,
const EmitBufferCB& emit_buffer_cb);
virtual ~EsParserH264();
virtual bool Parse(const uint8* buf, int size,
base::TimeDelta pts,
base::TimeDelta dts) OVERRIDE;
virtual void Flush() OVERRIDE;
virtual void Reset() OVERRIDE;
private:
struct TimingDesc {
base::TimeDelta dts;
base::TimeDelta pts;
};
bool FindAUD(int64* stream_pos);
bool ParseInternal();
bool EmitFrame(int64 access_unit_pos, int access_unit_size,
bool is_key_frame, int pps_id);
bool UpdateVideoDecoderConfig(const H264SPS* sps);
NewVideoConfigCB new_video_config_cb_;
EmitBufferCB emit_buffer_cb_;
scoped_ptr<media::OffsetByteQueue> es_queue_;
std::list<std::pair<int64, TimingDesc> > timing_desc_list_;
scoped_ptr<H264Parser> h264_parser_;
int64 current_access_unit_pos_;
int64 next_access_unit_pos_;
VideoDecoderConfig last_video_decoder_config_;
};
}
}
#endif