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_STREAM_INFO_H_
|
|
|
|
#define MEDIA_BASE_STREAM_INFO_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/base/memory/ref_counted.h"
|
2013-09-24 04:17:12 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-09-24 04:17:12 +00:00
|
|
|
namespace media {
|
|
|
|
|
|
|
|
enum StreamType {
|
2014-06-27 23:07:36 +00:00
|
|
|
kStreamUnknown = 0,
|
2013-09-24 04:17:12 +00:00
|
|
|
kStreamAudio,
|
|
|
|
kStreamVideo,
|
2015-10-14 23:12:10 +00:00
|
|
|
kStreamText,
|
2013-09-24 04:17:12 +00:00
|
|
|
};
|
|
|
|
|
2016-07-27 00:51:08 +00:00
|
|
|
enum Codec {
|
|
|
|
kUnknownCodec = 0,
|
|
|
|
kCodecH264,
|
|
|
|
kCodecHEV1,
|
|
|
|
kCodecHVC1,
|
|
|
|
kCodecVC1,
|
|
|
|
kCodecMPEG2,
|
|
|
|
kCodecMPEG4,
|
|
|
|
kCodecTheora,
|
|
|
|
kCodecVP8,
|
|
|
|
kCodecVP9,
|
|
|
|
kCodecVP10,
|
|
|
|
kCodecAAC,
|
|
|
|
kCodecAC3,
|
|
|
|
kCodecDTSC,
|
|
|
|
kCodecDTSE,
|
|
|
|
kCodecDTSH,
|
|
|
|
kCodecDTSL,
|
|
|
|
kCodecDTSM,
|
|
|
|
kCodecDTSP,
|
|
|
|
kCodecEAC3,
|
|
|
|
kCodecOpus,
|
|
|
|
kCodecVorbis,
|
|
|
|
kCodecText,
|
|
|
|
kNumCodec
|
|
|
|
};
|
|
|
|
|
2014-01-24 18:46:46 +00:00
|
|
|
/// Abstract class holds stream information.
|
2013-11-12 20:32:44 +00:00
|
|
|
class StreamInfo : public base::RefCountedThreadSafe<StreamInfo> {
|
2013-09-24 04:17:12 +00:00
|
|
|
public:
|
2016-07-27 00:51:08 +00:00
|
|
|
StreamInfo(StreamType stream_type, int track_id, uint32_t time_scale,
|
|
|
|
uint64_t duration, Codec codec, const std::string& codec_string,
|
|
|
|
const uint8_t* codec_config, size_t codec_config_size,
|
|
|
|
const std::string& language, bool is_encrypted);
|
2013-09-24 04:17:12 +00:00
|
|
|
|
2014-01-24 18:46:46 +00:00
|
|
|
/// @return true if this object has appropriate configuration values, false
|
|
|
|
/// otherwise.
|
2013-09-24 04:17:12 +00:00
|
|
|
virtual bool IsValidConfig() const = 0;
|
|
|
|
|
2014-01-24 18:46:46 +00:00
|
|
|
/// @return A human-readable string describing the stream info.
|
2013-10-14 20:55:48 +00:00
|
|
|
virtual std::string ToString() const;
|
2013-09-24 04:17:12 +00:00
|
|
|
|
|
|
|
StreamType stream_type() const { return stream_type_; }
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t track_id() const { return track_id_; }
|
|
|
|
uint32_t time_scale() const { return time_scale_; }
|
|
|
|
uint64_t duration() const { return duration_; }
|
2016-07-27 00:51:08 +00:00
|
|
|
Codec codec() const { return codec_; }
|
2013-10-14 20:55:48 +00:00
|
|
|
const std::string& codec_string() const { return codec_string_; }
|
2016-07-27 00:51:08 +00:00
|
|
|
const std::vector<uint8_t>& codec_config() const { return codec_config_; }
|
2013-10-14 20:55:48 +00:00
|
|
|
const std::string& language() const { return language_; }
|
2013-09-24 04:17:12 +00:00
|
|
|
bool is_encrypted() const { return is_encrypted_; }
|
|
|
|
|
2013-10-14 20:55:48 +00:00
|
|
|
void set_duration(int duration) { duration_ = duration; }
|
2016-07-27 00:51:08 +00:00
|
|
|
void set_codec(Codec codec) { codec_ = codec; }
|
2016-06-27 19:30:32 +00:00
|
|
|
void set_codec_config(const std::vector<uint8_t>& data) { codec_config_ = data; }
|
2014-07-14 21:35:57 +00:00
|
|
|
void set_codec_string(const std::string& codec_string) {
|
|
|
|
codec_string_ = codec_string;
|
|
|
|
}
|
2015-02-02 19:27:32 +00:00
|
|
|
void set_language(const std::string& language) { language_ = language; }
|
|
|
|
|
2014-01-16 00:52:07 +00:00
|
|
|
protected:
|
|
|
|
friend class base::RefCountedThreadSafe<StreamInfo>;
|
|
|
|
virtual ~StreamInfo();
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
private:
|
|
|
|
// Whether the stream is Audio or Video.
|
|
|
|
StreamType stream_type_;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t track_id_;
|
2013-10-14 20:55:48 +00:00
|
|
|
// The actual time is calculated as time / time_scale_ in seconds.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t time_scale_;
|
2013-10-14 20:55:48 +00:00
|
|
|
// Duration base on time_scale.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint64_t duration_;
|
2016-07-27 00:51:08 +00:00
|
|
|
Codec codec_;
|
2013-10-14 20:55:48 +00:00
|
|
|
std::string codec_string_;
|
|
|
|
std::string language_;
|
2013-09-24 04:17:12 +00:00
|
|
|
// Whether the stream is potentially encrypted.
|
|
|
|
// Note that in a potentially encrypted stream, individual buffers
|
|
|
|
// can be encrypted or not encrypted.
|
|
|
|
bool is_encrypted_;
|
|
|
|
// Optional byte data required for some audio/video decoders such as Vorbis
|
|
|
|
// codebooks.
|
2016-06-27 19:30:32 +00:00
|
|
|
std::vector<uint8_t> codec_config_;
|
2013-09-24 04:17:12 +00:00
|
|
|
|
|
|
|
// Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
|
|
|
|
// generated copy constructor and assignment operator. Since the extra data is
|
|
|
|
// typically small, the performance impact is minimal.
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2013-09-24 04:17:12 +00:00
|
|
|
|
|
|
|
#endif // MEDIA_BASE_STREAM_INFO_H_
|