ref: 528eeb796b548555b3d32119c4510f2cc277ad0f
parent: b890573fa1aa6ef5c6e4bc64eba64dd220ad09c1
author: menno <menno>
date: Sun Oct 20 11:43:30 EDT 2002
Updated MP4 libraries
--- a/common/mp4av/l16.cpp
+++ b/common/mp4av/l16.cpp
@@ -91,7 +91,7 @@
return false;
}
- payload = 0;
+ payload = MP4_SET_DYNAMIC_PAYLOAD;
if (MP4GetTrackTimeScale(mp4file, trackid) == 44100) {
if (chans == 1) payload = 11;
else if (chans == 2) payload = 10;
--- a/common/mp4av/libmp4av_st.dsp
+++ b/common/mp4av/libmp4av_st.dsp
@@ -64,7 +64,7 @@
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\mp4v2" /I ".\\" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\mp4v2" /I ".\\" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
--- a/common/mp4av/libmp4av_st.vcproj
+++ b/common/mp4av/libmp4av_st.vcproj
@@ -25,7 +25,7 @@
AdditionalIncludeDirectories="..\mp4v2,.\"
PreprocessorDefinitions="WIN32,NDEBUG,_LIB"
StringPooling="TRUE"
- RuntimeLibrary="4"
+ RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/libmp4av_st.pch"
@@ -69,8 +69,8 @@
Optimization="0"
AdditionalIncludeDirectories="..\mp4v2,.\"
PreprocessorDefinitions="WIN32,_DEBUG,_LIB"
- BasicRuntimeChecks="3"
- RuntimeLibrary="5"
+ BasicRuntimeChecks="0"
+ RuntimeLibrary="1"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/libmp4av_st.pch"
AssemblerListingLocation=".\Debug/"
--- a/common/mp4av/mpeg4.cpp
+++ b/common/mp4av/mpeg4.cpp
@@ -128,7 +128,7 @@
vol.SkipBits(1); // random accessible vol
vol.SkipBits(8); // object type id
- u_int8_t verid = 0;
+ u_int8_t verid = 1;
if (vol.GetBits(1)) { // is object layer id
verid = vol.GetBits(4); // object layer verid
vol.SkipBits(3); // object layer priority
--- a/common/mp4av/rfc2250.cpp
+++ b/common/mp4av/rfc2250.cpp
@@ -65,7 +65,8 @@
return false;
}
- u_int8_t payloadNumber = 0; // use dynamic payload number
+ u_int8_t payloadNumber = MP4_SET_DYNAMIC_PAYLOAD;
+ // use dynamic payload number
if (MP4GetTrackTimeScale(mp4File, mediaTrackId) == 90000) {
payloadNumber = 14;
--- a/common/mp4av/rfc3016.cpp
+++ b/common/mp4av/rfc3016.cpp
@@ -46,7 +46,7 @@
return false;
}
- u_int8_t payloadNumber = 0;
+ u_int8_t payloadNumber = MP4_SET_DYNAMIC_PAYLOAD;
MP4SetHintTrackRtpPayload(mp4File, hintTrackId,
"MP4V-ES", &payloadNumber, 0);
--- a/common/mp4av/rfc3119.cpp
+++ b/common/mp4av/rfc3119.cpp
@@ -446,7 +446,7 @@
doInterleave = interleave;
- u_int8_t payloadNumber = 0;
+ u_int8_t payloadNumber = MP4_SET_DYNAMIC_PAYLOAD;
MP4SetHintTrackRtpPayload(mp4File, hintTrackId,
"mpa-robust", &payloadNumber, 0);
--- a/common/mp4av/rfcisma.cpp
+++ b/common/mp4av/rfcisma.cpp
@@ -251,7 +251,7 @@
return false;
}
- u_int8_t payloadNumber = 0;
+ u_int8_t payloadNumber = MP4_SET_DYNAMIC_PAYLOAD;
char buffer[10];
if (channels != 1) {
snprintf(buffer, sizeof(buffer), "%u", channels);
--- a/common/mp4v2/isma.cpp
+++ b/common/mp4v2/isma.cpp
@@ -22,7 +22,7 @@
#include "mp4common.h"
static u_int8_t BifsV2Config[3] = {
- 0x00, 0x00, 0x40 // IsCommandStream
+ 0x00, 0x00, 0x60 // IsCommandStream = 1, PixelMetric = 1
};
void MP4File::MakeIsmaCompliant(bool addIsmaComplianceSdp)
@@ -787,16 +787,20 @@
// from ISMA 1.0 Tech Spec Appendix E
static u_int8_t bifsAudioOnly[] = {
0xC0, 0x10, 0x12,
- 0x81, 0x30, 0x2A, 0x05, 0x7C
+ 0x81, 0x30, 0x2A, 0x05, 0x6D, 0xC0
};
static u_int8_t bifsVideoOnly[] = {
0xC0, 0x10, 0x12,
- 0x61, 0x04, 0x88, 0x50, 0x45, 0x05, 0x3F, 0x00
+ 0x61, 0x04,
+ 0x1F, 0xC0, 0x00, 0x00,
+ 0x1F, 0xC0, 0x00, 0x00,
+ 0x44, 0x28, 0x22, 0x82, 0x9F, 0x80
};
static u_int8_t bifsAudioVideo[] = {
0xC0, 0x10, 0x12,
- 0x81, 0x30, 0x2A, 0x05, 0x72,
- 0x61, 0x04, 0x88, 0x50, 0x45, 0x05, 0x3F, 0x00
+ 0x81, 0x30, 0x2A, 0x05, 0x6D, 0x26,
+ 0x10, 0x41, 0xFC, 0x00, 0x00, 0x01, 0xFC, 0x00, 0x00,
+ 0x04, 0x42, 0x82, 0x28, 0x29, 0xF8
};
if (hasAudio && hasVideo) {
--- a/common/mp4v2/libmp4v2_st60.vcproj
+++ b/common/mp4v2/libmp4v2_st60.vcproj
@@ -65,7 +65,7 @@
Optimization="0"
AdditionalIncludeDirectories=".\"
PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS"
- RuntimeLibrary="5"
+ RuntimeLibrary="1"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\ST_Debug/libmp4v2_st60.pch"
AssemblerListingLocation=".\ST_Debug/"
--- a/common/mp4v2/mp4.cpp
+++ b/common/mp4v2/mp4.cpp
@@ -687,6 +687,7 @@
// but caller can adjust later to fit their desires
char* payloadName = NULL;
+ char *encodingParms = NULL;
u_int8_t payloadNumber;
u_int16_t maxPayloadSize;
@@ -695,7 +696,8 @@
srcTrackId,
&payloadName,
&payloadNumber,
- &maxPayloadSize);
+ &maxPayloadSize,
+ &encodingParms);
MP4SetHintTrackRtpPayload(
dstFile,
@@ -702,7 +704,8 @@
dstTrackId,
payloadName,
&payloadNumber,
- maxPayloadSize);
+ maxPayloadSize,
+ encodingParms);
MP4SetHintTrackSdp(
dstFile,
@@ -1667,12 +1670,14 @@
MP4TrackId hintTrackId,
char** ppPayloadName,
u_int8_t* pPayloadNumber,
- u_int16_t* pMaxPayloadSize)
+ u_int16_t* pMaxPayloadSize,
+ char **ppEncodingParams)
{
if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
try {
((MP4File*)hFile)->GetHintTrackRtpPayload(
- hintTrackId, ppPayloadName, pPayloadNumber, pMaxPayloadSize);
+ hintTrackId, ppPayloadName, pPayloadNumber, pMaxPayloadSize,
+ ppEncodingParams);
return true;
}
catch (MP4Error* e) {
@@ -1688,12 +1693,13 @@
MP4TrackId hintTrackId,
const char* pPayloadName,
u_int8_t* pPayloadNumber,
- u_int16_t maxPayloadSize)
+ u_int16_t maxPayloadSize,
+ const char *encode_params)
{
if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
try {
((MP4File*)hFile)->SetHintTrackRtpPayload(
- hintTrackId, pPayloadName, pPayloadNumber, maxPayloadSize);
+ hintTrackId, pPayloadName, pPayloadNumber, maxPayloadSize, encode_params);
return true;
}
catch (MP4Error* e) {
--- a/common/mp4v2/mp4.h
+++ b/common/mp4v2/mp4.h
@@ -133,11 +133,13 @@
#define MP4_MPEG2_AAC_AUDIO_TYPE MP4_MPEG2_AAC_MAIN_AUDIO_TYPE
#define MP4_MPEG4_AUDIO_TYPE 0x40
#define MP4_PRIVATE_AUDIO_TYPE 0xC0
-#define MP4_PCM16_AUDIO_TYPE 0xE0 /* a private definition */
+#define MP4_PCM16_LITTLE_ENDIAN_AUDIO_TYPE 0xE0 /* a private definition */
#define MP4_VORBIS_AUDIO_TYPE 0xE1 /* a private definition */
#define MP4_AC3_AUDIO_TYPE 0xE2 /* a private definition */
#define MP4_ALAW_AUDIO_TYPE 0xE3 /* a private definition */
#define MP4_ULAW_AUDIO_TYPE 0xE4 /* a private definition */
+#define MP4_G723_AUDIO_TYPE 0xE5 /* a private definition */
+#define MP4_PCM16_BIG_ENDIAN_AUDIO_TYPE 0xE6 /* a private definition */
/* MP4 MPEG-4 Audio types from 14496-3 Table 1.5.1 */
#define MP4_MPEG4_INVALID_AUDIO_TYPE 0
@@ -605,14 +607,18 @@
MP4TrackId hintTrackId,
char** ppPayloadName DEFAULT(NULL),
u_int8_t* pPayloadNumber DEFAULT(NULL),
- u_int16_t* pMaxPayloadSize DEFAULT(NULL));
+ u_int16_t* pMaxPayloadSize DEFAULT(NULL),
+ char **ppEncodingParams DEFAULT(NULL));
+#define MP4_SET_DYNAMIC_PAYLOAD 0xff
+
bool MP4SetHintTrackRtpPayload(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
const char* pPayloadName,
u_int8_t* pPayloadNumber,
- u_int16_t maxPayloadSize DEFAULT(0));
+ u_int16_t maxPayloadSize DEFAULT(0),
+ const char *encode_params DEFAULT(NULL));
const char* MP4GetSessionSdp(
MP4FileHandle hFile);
--- a/common/mp4v2/mp4file.cpp
+++ b/common/mp4v2/mp4file.cpp
@@ -1261,10 +1261,10 @@
return m_pTracks.Size();
}
- u_int16_t typeSeen = 0;
+ u_int32_t typeSeen = 0;
const char* normType = MP4Track::NormalizeTrackType(type);
- for (u_int16_t i = 0; i < m_pTracks.Size(); i++) {
+ for (u_int32_t i = 0; i < m_pTracks.Size(); i++) {
if (!strcmp(normType, m_pTracks[i]->GetType())) {
if (subType) {
if (normType == MP4_AUDIO_TRACK_TYPE) {
@@ -1317,7 +1317,7 @@
}
// extreme case where mp4 file has 2^16 tracks in it
- throw new MP4Error("too many exising tracks", "AddTrack");
+ throw new MP4Error("too many existing tracks", "AddTrack");
return MP4_INVALID_TRACK_ID; // to keep MSVC happy
}
@@ -1328,10 +1328,10 @@
return m_pTracks[trackIndex]->GetId();
}
- u_int16_t typeSeen = 0;
+ u_int32_t typeSeen = 0;
const char* normType = MP4Track::NormalizeTrackType(type);
- for (u_int16_t i = 0; i < m_pTracks.Size(); i++) {
+ for (u_int32_t i = 0; i < m_pTracks.Size(); i++) {
if (!strcmp(normType, m_pTracks[i]->GetType())) {
if (subType) {
if (normType == MP4_AUDIO_TRACK_TYPE) {
@@ -1362,9 +1362,9 @@
u_int16_t MP4File::FindTrackIndex(MP4TrackId trackId)
{
- for (u_int16_t i = 0; i < m_pTracks.Size(); i++) {
+ for (u_int32_t i = 0; i < m_pTracks.Size() && i <= 0xFFFF; i++) {
if (m_pTracks[i]->GetId() == trackId) {
- return i;
+ return (u_int16_t)i;
}
}
@@ -1818,7 +1818,8 @@
MP4TrackId hintTrackId,
char** ppPayloadName,
u_int8_t* pPayloadNumber,
- u_int16_t* pMaxPayloadSize)
+ u_int16_t* pMaxPayloadSize,
+ char **ppEncodingParams)
{
MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
@@ -1828,11 +1829,12 @@
}
((MP4RtpHintTrack*)pTrack)->GetPayload(
- ppPayloadName, pPayloadNumber, pMaxPayloadSize);
+ ppPayloadName, pPayloadNumber, pMaxPayloadSize, ppEncodingParams);
}
void MP4File::SetHintTrackRtpPayload(MP4TrackId hintTrackId,
- const char* payloadName, u_int8_t* pPayloadNumber, u_int16_t maxPayloadSize)
+ const char* payloadName, u_int8_t* pPayloadNumber, u_int16_t maxPayloadSize,
+ const char *encoding_params)
{
MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
@@ -1842,7 +1844,7 @@
}
u_int8_t payloadNumber;
- if (pPayloadNumber && *pPayloadNumber != 0) {
+ if (pPayloadNumber && *pPayloadNumber != MP4_SET_DYNAMIC_PAYLOAD) {
payloadNumber = *pPayloadNumber;
} else {
payloadNumber = AllocRtpPayloadNumber();
@@ -1852,7 +1854,7 @@
}
((MP4RtpHintTrack*)pTrack)->SetPayload(
- payloadName, payloadNumber, maxPayloadSize);
+ payloadName, payloadNumber, maxPayloadSize, encoding_params);
}
u_int8_t MP4File::AllocRtpPayloadNumber()
--- a/common/mp4v2/mp4file.h
+++ b/common/mp4v2/mp4file.h
@@ -276,13 +276,15 @@
MP4TrackId hintTrackId,
char** ppPayloadName = NULL,
u_int8_t* pPayloadNumber = NULL,
- u_int16_t* pMaxPayloadSize = NULL);
+ u_int16_t* pMaxPayloadSize = NULL,
+ char **ppEncodingParams = NULL);
void SetHintTrackRtpPayload(
MP4TrackId hintTrackId,
const char* payloadName,
u_int8_t* pPayloadNumber,
- u_int16_t maxPayloadSize);
+ u_int16_t maxPayloadSize,
+ const char *encoding_params);
MP4TrackId GetHintTrackReferenceTrackId(
MP4TrackId hintTrackId);
--- a/common/mp4v2/mp4file_io.cpp
+++ b/common/mp4v2/mp4file_io.cpp
@@ -64,6 +64,7 @@
}
} else {
if (pos >= m_memoryBufferSize) {
+ // abort();
throw new MP4Error("position out of range", "MP4SetPosition");
}
m_memoryBufferPosition = pos;
@@ -139,7 +140,7 @@
if (numBytes) {
m_memoryBufferSize = numBytes;
} else {
- m_memoryBufferSize = 1024;
+ m_memoryBufferSize = 4096;
}
m_memoryBuffer = (u_int8_t*)MP4Malloc(m_memoryBufferSize);
}
--- a/common/mp4v2/mp4info.cpp
+++ b/common/mp4v2/mp4info.cpp
@@ -49,10 +49,12 @@
MP4_MPEG2_AAC_SSR_AUDIO_TYPE, // 0x68
MP4_MPEG2_AUDIO_TYPE, // 0x69
MP4_MPEG1_AUDIO_TYPE, // 0x6B
- MP4_PCM16_AUDIO_TYPE,
+ MP4_PCM16_LITTLE_ENDIAN_AUDIO_TYPE,
MP4_VORBIS_AUDIO_TYPE,
MP4_ALAW_AUDIO_TYPE,
MP4_ULAW_AUDIO_TYPE,
+ MP4_G723_AUDIO_TYPE,
+ MP4_PCM16_BIG_ENDIAN_AUDIO_TYPE,
};
static const char* mpegAudioNames[] = {
"MPEG-2 AAC Main",
@@ -60,10 +62,12 @@
"MPEG-2 AAC SSR",
"MPEG-2 (MP3)",
"MPEG-1 (MP3)",
- "PCM16",
+ "PCM16 (little endian)",
"OGG VORBIS",
"G.711 aLaw",
"G.711 uLaw",
+ "G.723.1",
+ "PCM16 (big endian)",
};
static u_int8_t numMpegAudioTypes =
sizeof(mpegAudioTypes) / sizeof(u_int8_t);
--- a/common/mp4v2/mp4property.cpp
+++ b/common/mp4v2/mp4property.cpp
@@ -195,7 +195,7 @@
}
Indent(pFile, indent);
fprintf(pFile,
-#ifdef WIN32
+#ifdef _WIN32
"%s = "LLU" (0x%016I64x)\n",
#else
"%s = "LLU" (0x%016llx)\n",
@@ -234,7 +234,7 @@
hexWidth++;
}
fprintf(pFile,
-#ifdef WIN32
+#ifdef _WIN32
"%s = "LLU" (0x%0*I64x) <%u bits>\n",
#else
"%s = "LLU" (0x%0*llx) <%u bits>\n",
--- a/common/mp4v2/rtphint.cpp
+++ b/common/mp4v2/rtphint.cpp
@@ -310,11 +310,16 @@
void MP4RtpHintTrack::GetPayload(
char** ppPayloadName,
u_int8_t* pPayloadNumber,
- u_int16_t* pMaxPayloadSize)
+ u_int16_t* pMaxPayloadSize,
+ char **ppEncodingParams)
{
InitPayload();
- if (ppPayloadName) {
+ if (ppPayloadName || ppEncodingParams) {
+ if (ppPayloadName)
+ *ppPayloadName = NULL;
+ if (ppEncodingParams)
+ *ppEncodingParams = NULL;
if (m_pRtpMapProperty) {
const char* pRtpMap = m_pRtpMapProperty->GetValue();
char* pSlash = strchr(pRtpMap, '/');
@@ -326,11 +331,22 @@
length = strlen(pRtpMap);
}
- *ppPayloadName = (char*)MP4Calloc(length + 1);
- strncpy(*ppPayloadName, pRtpMap, length);
- } else {
- *ppPayloadName = NULL;
- }
+ if (ppPayloadName) {
+ *ppPayloadName = (char*)MP4Calloc(length + 1);
+ strncpy(*ppPayloadName, pRtpMap, length);
+ }
+ if (pSlash && ppEncodingParams) {
+ pSlash = strchr(pSlash, '/');
+ if (pSlash != NULL) {
+ pSlash++;
+ if (pSlash != '\0') {
+ length = strlen(pRtpMap) - (pSlash - pRtpMap);
+ *ppEncodingParams = (char *)MP4Calloc(length + 1);
+ strncpy(*ppEncodingParams, pSlash, length);
+ }
+ }
+ }
+ }
}
if (pPayloadNumber) {
@@ -353,7 +369,8 @@
void MP4RtpHintTrack::SetPayload(
const char* payloadName,
u_int8_t payloadNumber,
- u_int16_t maxPayloadSize)
+ u_int16_t maxPayloadSize,
+ const char *encoding_parms)
{
InitRefTrack();
InitPayload();
@@ -361,9 +378,23 @@
ASSERT(m_pRtpMapProperty);
ASSERT(m_pPayloadNumberProperty);
ASSERT(m_pMaxPacketSizeProperty);
+
+ size_t len = strlen(payloadName) + 16;
+ if (encoding_parms != NULL) {
+ size_t temp = strlen(encoding_parms);
+ if (temp == 0) {
+ encoding_parms = NULL;
+ } else {
+ len += temp;
+ }
+ }
- char* rtpMapBuf = (char*)MP4Malloc(strlen(payloadName) + 16);
- sprintf(rtpMapBuf, "%s/%u", payloadName, GetTimeScale());
+ char* rtpMapBuf = (char*)MP4Malloc(len);
+ sprintf(rtpMapBuf, "%s/%u%c%s",
+ payloadName,
+ GetTimeScale(),
+ encoding_parms != NULL ? '/' : '\0',
+ encoding_parms == NULL ? "" : encoding_parms);
m_pRtpMapProperty->SetValue(rtpMapBuf);
m_pPayloadNumberProperty->SetValue(payloadNumber);
--- a/common/mp4v2/rtphint.h
+++ b/common/mp4v2/rtphint.h
@@ -252,12 +252,14 @@
void GetPayload(
char** ppPayloadName = NULL,
u_int8_t* pPayloadNumber = NULL,
- u_int16_t* pMaxPayloadSize = NULL);
+ u_int16_t* pMaxPayloadSize = NULL,
+ char **ppEncodingParams = NULL);
void SetPayload(
const char* payloadName,
u_int8_t payloadNumber,
- u_int16_t maxPayloadSize);
+ u_int16_t maxPayloadSize,
+ const char *encoding_parms);
void ReadHint(
MP4SampleId hintSampleId,