2014-02-14 23:21:05 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
2013-09-24 04:17:12 +00:00
|
|
|
|
|
|
|
#ifndef MEDIA_BASE_MEDIA_PARSER_H_
|
|
|
|
#define MEDIA_BASE_MEDIA_PARSER_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "base/callback.h"
|
|
|
|
#include "base/memory/ref_counted.h"
|
|
|
|
#include "base/memory/scoped_ptr.h"
|
|
|
|
#include "media/base/container_names.h"
|
|
|
|
|
|
|
|
namespace media {
|
|
|
|
|
|
|
|
class MediaSample;
|
|
|
|
class StreamInfo;
|
|
|
|
|
|
|
|
class MediaParser {
|
|
|
|
public:
|
|
|
|
MediaParser() {}
|
|
|
|
virtual ~MediaParser() {}
|
|
|
|
|
|
|
|
// Indicates completion of parser initialization.
|
2013-10-11 21:44:55 +00:00
|
|
|
// First parameter - A vector of all the elementary streams within this file.
|
|
|
|
typedef base::Callback<void(const std::vector<scoped_refptr<StreamInfo> >&)>
|
2013-09-24 04:17:12 +00:00
|
|
|
InitCB;
|
|
|
|
|
|
|
|
// New stream sample have been parsed.
|
|
|
|
// First parameter - The track id of the new sample.
|
2013-10-11 21:44:55 +00:00
|
|
|
// Second parameter - The new media sample.
|
2013-09-24 04:17:12 +00:00
|
|
|
// Return value - True indicates that the sample is accepted.
|
|
|
|
// False if something was wrong with the sample and a parsing
|
|
|
|
// error should be signaled.
|
|
|
|
typedef base::Callback<
|
|
|
|
bool(uint32 track_id, const scoped_refptr<MediaSample>&)>
|
|
|
|
NewSampleCB;
|
|
|
|
|
|
|
|
// A new potentially encrypted stream has been parsed.
|
|
|
|
// First Parameter - Container name.
|
|
|
|
// Second parameter - The initialization data associated with the stream.
|
|
|
|
// Third parameter - Number of bytes of the initialization data.
|
|
|
|
typedef base::Callback<void(MediaContainerName, scoped_ptr<uint8[]>, int)>
|
|
|
|
NeedKeyCB;
|
|
|
|
|
|
|
|
// Initialize the parser with necessary callbacks. Must be called before any
|
|
|
|
// data is passed to Parse(). |init_cb| will be called once enough data has
|
|
|
|
// been parsed to determine the initial stream configurations.
|
|
|
|
virtual void Init(const InitCB& init_cb,
|
|
|
|
const NewSampleCB& new_sample_cb,
|
|
|
|
const NeedKeyCB& need_key_cb) = 0;
|
|
|
|
|
|
|
|
// Called when there is new data to parse.
|
|
|
|
//
|
|
|
|
// Returns true if the parse succeeds.
|
2014-03-26 22:09:43 +00:00
|
|
|
// NOTE: Change to return Status.
|
2013-09-24 04:17:12 +00:00
|
|
|
virtual bool Parse(const uint8* buf, int size) = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(MediaParser);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
|
|
|
|
|
|
|
#endif // MEDIA_BASE_MEDIA_PARSER_H_
|