2013-10-11 21:44:55 +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.
|
2013-11-12 20:37:58 +00:00
|
|
|
//
|
|
|
|
// Defines the muxer interface.
|
2013-10-11 21:44:55 +00:00
|
|
|
|
|
|
|
#ifndef MEDIA_BASE_MUXER_H_
|
|
|
|
#define MEDIA_BASE_MUXER_H_
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "base/memory/ref_counted.h"
|
|
|
|
#include "base/memory/scoped_ptr.h"
|
2013-11-12 20:37:58 +00:00
|
|
|
#include "media/base/muxer_options.h"
|
2013-10-11 21:44:55 +00:00
|
|
|
#include "media/base/status.h"
|
|
|
|
|
|
|
|
namespace media {
|
|
|
|
|
|
|
|
class EncryptorSource;
|
|
|
|
class MediaSample;
|
|
|
|
class MediaStream;
|
|
|
|
|
|
|
|
class Muxer {
|
|
|
|
public:
|
2014-01-14 01:38:34 +00:00
|
|
|
explicit Muxer(const MuxerOptions& options);
|
2013-10-11 21:44:55 +00:00
|
|
|
virtual ~Muxer();
|
|
|
|
|
2014-01-14 01:38:34 +00:00
|
|
|
// Set encryptor source. Caller retains ownership of |encryptor_source|.
|
|
|
|
// Should be called before calling Initialize().
|
|
|
|
void SetEncryptorSource(EncryptorSource* encryptor_source,
|
|
|
|
double clear_lead_in_seconds);
|
|
|
|
|
2013-11-12 20:37:58 +00:00
|
|
|
// Initialize the muxer. Must be called after connecting all the streams.
|
|
|
|
virtual Status Initialize() = 0;
|
|
|
|
|
|
|
|
// Final clean up.
|
|
|
|
virtual Status Finalize() = 0;
|
|
|
|
|
2013-10-11 21:44:55 +00:00
|
|
|
// Adds video/audio stream.
|
|
|
|
virtual Status AddStream(MediaStream* stream);
|
|
|
|
|
|
|
|
// Adds new media sample.
|
|
|
|
virtual Status AddSample(const MediaStream* stream,
|
|
|
|
scoped_refptr<MediaSample> sample) = 0;
|
|
|
|
|
|
|
|
// Drives the remuxing from muxer side (pull).
|
|
|
|
virtual Status Run();
|
|
|
|
|
2013-11-12 20:37:58 +00:00
|
|
|
const std::vector<MediaStream*>& streams() const { return streams_; }
|
2013-10-11 21:44:55 +00:00
|
|
|
|
2013-11-12 20:37:58 +00:00
|
|
|
protected:
|
|
|
|
const MuxerOptions& options() const { return options_; }
|
|
|
|
EncryptorSource* encryptor_source() { return encryptor_source_; }
|
2014-01-14 01:38:34 +00:00
|
|
|
double clear_lead_in_seconds() const { return clear_lead_in_seconds_; }
|
2013-10-11 21:44:55 +00:00
|
|
|
|
|
|
|
private:
|
2013-11-12 20:37:58 +00:00
|
|
|
MuxerOptions options_;
|
2013-10-11 21:44:55 +00:00
|
|
|
std::vector<MediaStream*> streams_;
|
2014-01-14 01:38:34 +00:00
|
|
|
EncryptorSource* encryptor_source_;
|
|
|
|
double clear_lead_in_seconds_;
|
2013-10-11 21:44:55 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Muxer);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
|
|
|
|
|
|
|
#endif // MEDIA_BASE_MUXER_H_
|