Integrate PackedAudioWriter

Closes #342.

Change-Id: I2fb4a651ad90448ab226b386c92c94e11ff9f9a8
This commit is contained in:
KongQun Yang 2018-05-07 16:08:09 -07:00
parent 39beb99d6c
commit 0af2c5cdcf
7 changed files with 51 additions and 25 deletions

View File

@ -16,28 +16,30 @@ Shaka Packager supports:
- [HLS](https://developer.apple.com/streaming/)
- Key systems:
- [Widevine](http://www.widevine.com/)
- [PlayReady](https://www.microsoft.com/playready/)<sup>1</sup>
- [Fairplay](https://developer.apple.com/streaming/fps/)<sup>1</sup>
- [PlayReady](https://www.microsoft.com/playready/)¹
- [Fairplay](https://developer.apple.com/streaming/fps/)¹
- Encryption standards:
- [CENC](https://en.wikipedia.org/wiki/MPEG_Common_Encryption)
- [SAMPLE-AES](https://developer.apple.com/library/content/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption/Intro/Intro.html)
- Media Containers and codecs
| Codecs | ISO-BMFF | WebM | MPEG2-TS | WVM |
|:-----------------:|:------------:|:------------:|:------------:|:-----------:|
| H264 (AVC) | I / O | - | I / O | I |
| H265 (HEVC) | I / O | - | I | - |
| VP8 | I / O | I / O | - | - |
| VP9 | I / O | I / O | - | - |
| AAC | I / O | - | I / O | I |
| Dolby AC3/EAC3 | I / O | - | I | - |
| DTS | I / O | - | - | - |
| FLAC | I / O | - | - | - |
| Opus | *I / O* | I / O | - | - |
| Vorbis | - | I / O | - | - |
| Codecs | ISO-BMFF | WebM | MPEG2-TS | WVM | Packed Audio²|
|:-----------------:|:------------:|:------------:|:------------:|:-----------:|:------------:|
| H264 (AVC) | I / O | - | I / O | I | - |
| H265 (HEVC) | I / O | - | I | - | - |
| VP8 | I / O | I / O | - | - | - |
| VP9 | I / O | I / O | - | - | - |
| AAC | I / O | - | I / O | I | O |
| Dolby AC3/EAC3 | I / O | - | I | - | O |
| DTS | I / O | - | - | - | - |
| FLAC | I / O | - | - | - | - |
| Opus | I / O³ | I / O | - | - | - |
| Vorbis | - | I / O | - | - | - |
** I for input and O for output.
** Opus support in ISO-BMFF is experimental.
NOTES:
- I for input and O for output.
- ²: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-3.4
- ³: Opus support in ISO-BMFF is experimental.
- Subtitles
- WebVTT in both text form and embedded in MP4
- TTML in text form (DASH only)

View File

@ -11,6 +11,7 @@
#include "packager/media/base/muxer_options.h"
#include "packager/media/formats/mp2t/ts_muxer.h"
#include "packager/media/formats/mp4/mp4_muxer.h"
#include "packager/media/formats/packed_audio/packed_audio_writer.h"
#include "packager/media/formats/webm/webm_muxer.h"
#include "packager/packager.h"
@ -34,6 +35,11 @@ std::shared_ptr<Muxer> MuxerFactory::CreateMuxer(
std::shared_ptr<Muxer> muxer;
switch (output_format) {
case CONTAINER_AAC:
case CONTAINER_AC3:
case CONTAINER_EAC3:
muxer = std::make_shared<PackedAudioWriter>(options);
break;
case CONTAINER_WEBM:
muxer = std::make_shared<webm::WebMMuxer>(options);
break;

View File

@ -1726,7 +1726,15 @@ MediaContainerName DetermineContainer(const uint8_t* buffer, int buffer_size) {
MediaContainerName DetermineContainerFromFormatName(
const std::string& format_name) {
if (base::EqualsCaseInsensitiveASCII(format_name, "webm")) {
if (base::EqualsCaseInsensitiveASCII(format_name, "aac") ||
base::EqualsCaseInsensitiveASCII(format_name, "adts")) {
return CONTAINER_AAC;
} else if (base::EqualsCaseInsensitiveASCII(format_name, "ac3")) {
return CONTAINER_AC3;
} else if (base::EqualsCaseInsensitiveASCII(format_name, "ec3") ||
base::EqualsCaseInsensitiveASCII(format_name, "eac3")) {
return CONTAINER_EAC3;
} else if (base::EqualsCaseInsensitiveASCII(format_name, "webm")) {
return CONTAINER_WEBM;
} else if (base::EqualsCaseInsensitiveASCII(format_name, "m4a") ||
base::EqualsCaseInsensitiveASCII(format_name, "m4v") ||

View File

@ -46,6 +46,9 @@ void SetMediaInfoContainerType(MuxerListener::ContainerType container_type,
case MuxerListener::kContainerMpeg2ts:
media_info->set_container_type(MediaInfo::CONTAINER_MPEG2_TS);
break;
case MuxerListener::kContainerPackedAudio:
media_info->set_container_type(MediaInfo::CONTAINER_PACKED_AUDIO);
break;
case MuxerListener::kContainerWebM:
media_info->set_container_type(MediaInfo::CONTAINER_WEBM);
break;

View File

@ -17,6 +17,7 @@ message MediaInfo {
CONTAINER_MPEG2_TS= 2;
CONTAINER_WEBM = 3;
CONTAINER_TEXT = 4;
CONTAINER_PACKED_AUDIO = 5;
}
message VideoInfo {

View File

@ -218,15 +218,17 @@ Status ValidateStreamDescriptor(bool dump_stream_info,
"All TS segments must be self-initializing. Stream "
"descriptors 'output' or 'init_segment' are not allowed.");
}
} else if (output_format == CONTAINER_WEBVTT) {
// There is no need for an init segment when outputting to WebVTT because
// there is no initialization data.
} else if (output_format == CONTAINER_WEBVTT ||
output_format == CONTAINER_AAC || output_format == CONTAINER_AC3 ||
output_format == CONTAINER_EAC3) {
// There is no need for an init segment when outputting because there is no
// initialization data.
if (stream.segment_template.length() && stream.output.length()) {
return Status(
error::INVALID_ARGUMENT,
"Segmented WebVTT output cannot have an init segment. Do not specify "
"stream descriptors 'output' or 'init_segment' when using "
"'segment_template' with WebVtt.");
"Segmented WebVTT or PackedAudio output cannot have an init segment. "
"Do not specify stream descriptors 'output' or 'init_segment' when "
"using 'segment_template'.");
}
} else {
// For any other format, if there is a segment template, there must be an
@ -386,8 +388,11 @@ std::shared_ptr<MediaHandler> CreateEncryptionHandler(
// Use Sample AES in MPEG2TS.
// TODO(kqyang): Consider adding a new flag to enable Sample AES as we
// will support CENC in TS in the future.
if (GetOutputFormat(stream) == CONTAINER_MPEG2TS) {
VLOG(1) << "Use Apple Sample AES encryption for MPEG2TS.";
if (GetOutputFormat(stream) == CONTAINER_MPEG2TS ||
GetOutputFormat(stream) == CONTAINER_AAC ||
GetOutputFormat(stream) == CONTAINER_AC3 ||
GetOutputFormat(stream) == CONTAINER_EAC3) {
VLOG(1) << "Use Apple Sample AES encryption for MPEG2TS or Packed Audio.";
encryption_params.protection_scheme = kAppleSampleAesProtectionScheme;
}

View File

@ -36,6 +36,7 @@
'media/event/media_event.gyp:media_event',
'media/formats/mp2t/mp2t.gyp:mp2t',
'media/formats/mp4/mp4.gyp:mp4',
'media/formats/packed_audio/packed_audio.gyp:packed_audio',
'media/formats/webm/webm.gyp:webm',
'media/formats/webvtt/webvtt.gyp:webvtt',
'media/formats/wvm/wvm.gyp:wvm',