2013-11-12 20:37:58 +00:00
|
|
|
// Copyright (c) 2013 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.
|
|
|
|
//
|
|
|
|
// Implements MP4 Muxer.
|
|
|
|
|
|
|
|
#ifndef MEDIA_MP4_MP4_MUXER_H_
|
|
|
|
#define MEDIA_MP4_MP4_MUXER_H_
|
|
|
|
|
2013-12-12 23:49:31 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2013-11-12 20:37:58 +00:00
|
|
|
#include "media/base/muxer.h"
|
|
|
|
#include "media/mp4/fourccs.h"
|
|
|
|
|
|
|
|
namespace media {
|
|
|
|
|
|
|
|
class AudioStreamInfo;
|
|
|
|
class StreamInfo;
|
|
|
|
class VideoStreamInfo;
|
|
|
|
|
|
|
|
namespace mp4 {
|
|
|
|
|
|
|
|
class MP4Segmenter;
|
|
|
|
|
|
|
|
struct ProtectionSchemeInfo;
|
|
|
|
struct ProtectionSystemSpecificHeader;
|
|
|
|
struct Track;
|
|
|
|
|
|
|
|
class MP4Muxer : public Muxer {
|
|
|
|
public:
|
2014-01-14 01:38:34 +00:00
|
|
|
explicit MP4Muxer(const MuxerOptions& options);
|
2013-11-12 20:37:58 +00:00
|
|
|
virtual ~MP4Muxer();
|
|
|
|
|
|
|
|
// Muxer implementations.
|
|
|
|
virtual Status Initialize() OVERRIDE;
|
|
|
|
virtual Status Finalize() OVERRIDE;
|
|
|
|
virtual Status AddSample(const MediaStream* stream,
|
|
|
|
scoped_refptr<MediaSample> sample) OVERRIDE;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Generate Audio/Video Track atom.
|
|
|
|
void InitializeTrak(const StreamInfo* info, Track* trak);
|
|
|
|
void GenerateAudioTrak(const AudioStreamInfo* audio_info,
|
|
|
|
Track* trak,
|
|
|
|
uint32 track_id);
|
|
|
|
void GenerateVideoTrak(const VideoStreamInfo* video_info,
|
|
|
|
Track* trak,
|
|
|
|
uint32 track_id);
|
|
|
|
|
|
|
|
// Generate Pssh atom.
|
|
|
|
void GeneratePssh(ProtectionSystemSpecificHeader* pssh);
|
|
|
|
|
|
|
|
// Generates a sinf atom with CENC encryption parameters.
|
|
|
|
void GenerateSinf(ProtectionSchemeInfo* sinf, FourCC old_type);
|
|
|
|
|
|
|
|
// Should we enable encrytion?
|
|
|
|
bool IsEncryptionRequired() { return (encryptor_source() != NULL); }
|
|
|
|
|
2013-12-12 23:49:31 +00:00
|
|
|
// Helper functions for events.
|
|
|
|
void GetStreamInfo(std::vector<StreamInfo*>* stream_infos);
|
|
|
|
|
|
|
|
// Gets |start| and |end| initialization range. Returns true if there is an
|
|
|
|
// init range and sets start-end byte-range-spec specified in RFC2616.
|
|
|
|
bool GetInitRangeStartAndEnd(uint32* start, uint32* end);
|
|
|
|
|
|
|
|
// Gets |start| and |end| index range. Returns true if there is an index range
|
|
|
|
// and sets start-end byte-range-spec specified in RFC2616.
|
|
|
|
bool GetIndexRangeStartAndEnd(uint32* start, uint32* end);
|
|
|
|
|
|
|
|
// Fire events if there are no errors and Muxer::muxer_listener() is not NULL.
|
|
|
|
void FireOnMediaStartEvent();
|
|
|
|
void FireOnMediaEndEvent();
|
|
|
|
|
2013-11-12 20:37:58 +00:00
|
|
|
scoped_ptr<MP4Segmenter> segmenter_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(MP4Muxer);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp4
|
|
|
|
} // namespace media
|
|
|
|
|
|
|
|
#endif // MEDIA_MP4_MP4_MUXER_H_
|