⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mp4info.cpp

📁 完整的RTP RTSP代码库
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is MPEG4IP. * * The Initial Developer of the Original Code is Cisco Systems Inc. * Portions created by Cisco Systems Inc. are * Copyright (C) Cisco Systems Inc. 2001-2002.  All Rights Reserved. *  * Portions created by Ximpo Group Ltd. are * Copyright (C) Ximpo Group Ltd. 2003, 2004.  All Rights Reserved. * * Contributor(s): *		Dave Mackie               dmackie@cisco.com *              Bill May                  wmay@cisco.com *		Alix Marchandise-Franquet alix@cisco.com *		Ximpo Group Ltd.          mp4v2@ximpo.com */#include "mp4common.h"static char* PrintAudioInfo(	MP4FileHandle mp4File,	MP4TrackId trackId){	static const char* mpeg4AudioNames[] = {		"MPEG-4 AAC main",		"MPEG-4 AAC LC",		"MPEG-4 AAC SSR",		"MPEG-4 AAC LTP",		"MPEG-4 AAC HE",		"MPEG-4 AAC Scalable",		"MPEG-4 TwinVQ",		"MPEG-4 CELP",		"MPEG-4 HVXC",		NULL, NULL,		"MPEG-4 TTSI",		"MPEG-4 Main Synthetic",		"MPEG-4 Wavetable Syn",		"MPEG-4 General MIDI",		"MPEG-4 Algo Syn and Audio FX",		"MPEG-4 ER AAC LC",		NULL,		"MPEG-4 ER AAC LTP",		"MPEG-4 ER AAC Scalable",		"MPEG-4 ER TwinVQ",		"MPEG-4 ER BSAC",		"MPEG-4 ER ACC LD",		"MPEG-4 ER CELP",		"MPEG-4 ER HVXC",		"MPEG-4 ER HILN",		"MPEG-4 ER Parametric",		"MPEG-4 SSC",		"MPEG-4 PS",		"MPEG-4 MPEG Surround",		NULL,		"MPEG-4 Layer-1",		"MPEG-4 Layer-2",		"MPEG-4 Layer-3",		"MPEG-4 DST",		"MPEG-4 Audio Lossless",		"MPEG-4 SLS",		"MPEG-4 SLS non-core", 	};	static const u_int8_t mpegAudioTypes[] = {		MP4_MPEG2_AAC_MAIN_AUDIO_TYPE,	// 0x66		MP4_MPEG2_AAC_LC_AUDIO_TYPE,	// 0x67		MP4_MPEG2_AAC_SSR_AUDIO_TYPE,	// 0x68		MP4_MPEG2_AUDIO_TYPE,			// 0x69		MP4_MPEG1_AUDIO_TYPE,			// 0x6B		// private types		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",		"MPEG-2 AAC LC",		"MPEG-2 AAC SSR",		"MPEG-2 Audio (13818-3)",		"MPEG-1 Audio (11172-3)",		// private types		"PCM16 (little endian)",		"Vorbis",		"G.711 aLaw",		"G.711 uLaw",		"G.723.1",		"PCM16 (big endian)",	};	u_int8_t numMpegAudioTypes =		sizeof(mpegAudioTypes) / sizeof(u_int8_t);	const char* typeName = "Unknown";	bool foundType = false;	u_int8_t type = 0;	const char *media_data_name;	media_data_name = MP4GetTrackMediaDataName(mp4File, trackId);	if (media_data_name == NULL) {	  typeName = "Unknown - no media data name";	} else if (strcasecmp(media_data_name, "samr") == 0) {	    typeName = "AMR";	    foundType = true;	} else if (strcasecmp(media_data_name, "sawb") == 0) {	    typeName = "AMR-WB";	    foundType = true;	} else if (strcasecmp(media_data_name, "mp4a") == 0) {	    	  type = MP4GetTrackEsdsObjectTypeId(mp4File, trackId);	  switch (type) {	  case MP4_INVALID_AUDIO_TYPE:	    typeName = "AAC from .mov";	    foundType = true;	    break;	  case MP4_MPEG4_AUDIO_TYPE:  {		    type = MP4GetTrackAudioMpeg4Type(mp4File, trackId);	    if (type == MP4_MPEG4_INVALID_AUDIO_TYPE ||		type > NUM_ELEMENTS_IN_ARRAY(mpeg4AudioNames) || 		mpeg4AudioNames[type - 1] == NULL) {	      typeName = "MPEG-4 Unknown Profile";	    } else {	      typeName = mpeg4AudioNames[type - 1];	      foundType = true;	    }	    break;	  }	    // fall through	  default:	    for (u_int8_t i = 0; i < numMpegAudioTypes; i++) {	      if (type == mpegAudioTypes[i]) {		typeName = mpegAudioNames[i];		foundType = true;		break;	      }	    }	  }	} else {	  typeName = media_data_name;	  foundType = true;	}	u_int32_t timeScale =		MP4GetTrackTimeScale(mp4File, trackId);	MP4Duration trackDuration =		MP4GetTrackDuration(mp4File, trackId);	double msDuration =		UINT64_TO_DOUBLE(MP4ConvertFromTrackDuration(mp4File, trackId,			trackDuration, MP4_MSECS_TIME_SCALE));	u_int32_t avgBitRate =		MP4GetTrackBitRate(mp4File, trackId);	char *sInfo = (char*)MP4Malloc(256);	// type duration avgBitrate samplingFrequency	if (foundType)	  snprintf(sInfo, 256, 		  "%u\taudio\t%s%s, %.3f secs, %u kbps, %u Hz\n",		  trackId,		  MP4IsIsmaCrypMediaTrack(mp4File, trackId) ? "enca - " : "",		  typeName,		  msDuration / 1000.0,		  (avgBitRate + 500) / 1000,		  timeScale);	else	  snprintf(sInfo, 256,		  "%u\taudio\t%s%s(%u), %.3f secs, %u kbps, %u Hz\n",		  trackId,		  MP4IsIsmaCrypMediaTrack(mp4File, trackId) ? "enca - " : "",		  typeName,		  type,		  msDuration / 1000.0,		  (avgBitRate + 500) / 1000,		  timeScale);	return sInfo;}static const struct {  uint8_t profile;  const char *name;} VisualProfileToName[] = {  { MPEG4_SP_L1, "MPEG-4 Simple @ L1"},  { MPEG4_SP_L2, "MPEG-4 Simple @ L2" },  { MPEG4_SP_L3, "MPEG-4 Simple @ L3" },  { MPEG4_SP_L0, "MPEG-4 Simple @ L0" },  { MPEG4_SSP_L1, "MPEG-4 Simple Scalable @ L1"},  { MPEG4_SSP_L2, "MPEG-4 Simple Scalable @ L2" },  { MPEG4_CP_L1, "MPEG-4 Core @ L1"},  { MPEG4_CP_L2, "MPEG-4 Core @ L2"},  { MPEG4_MP_L2, "MPEG-4 Main @ L2"},  { MPEG4_MP_L3, "MPEG-4 Main @ L3"},  { MPEG4_MP_L4, "MPEG-4 Main @ L4"},  { MPEG4_NBP_L2, "MPEG-4 N-bit @ L2"},  { MPEG4_STP_L1, "MPEG-4  Scalable Texture @ L1"},  { MPEG4_SFAP_L1, "MPEG-4 Simple Face Anim @ L1"},  { MPEG4_SFAP_L2, "MPEG-4  Simple Face Anim @ L2"},  { MPEG4_SFBAP_L1, "MPEG-4  Simple FBA @ L1"},  { MPEG4_SFBAP_L2, "MPEG-4 Simple FBA @ L2"},  { MPEG4_BATP_L1, "MPEG-4 Basic Anim Text @ L1"},  { MPEG4_BATP_L2, "MPEG-4 Basic Anim Text @ L2"},  { MPEG4_HP_L1, "MPEG-4 Hybrid @ L1"},  { MPEG4_HP_L2, "MPEG-4 Hybrid @ L2"},  { MPEG4_ARTSP_L1, "MPEG-4 Adv RT Simple @ L1"},  { MPEG4_ARTSP_L2, "MPEG-4 Adv RT Simple @ L2"},  { MPEG4_ARTSP_L3, "MPEG-4 Adv RT Simple @ L3"},  { MPEG4_ARTSP_L4, "MPEG-4 Adv RT Simple @ L4"},  { MPEG4_CSP_L1, "MPEG-4 Core Scalable @ L1"},  { MPEG4_CSP_L2, "MPEG-4 Core Scalable @ L2"},  { MPEG4_CSP_L3, "MPEG-4 Core Scalable @ L3"},  { MPEG4_ACEP_L1, "MPEG-4 Adv Coding Efficieny @ L1"},  { MPEG4_ACEP_L2, "MPEG-4 Adv Coding Efficieny @ L2"},  { MPEG4_ACEP_L3, "MPEG-4 Adv Coding Efficieny @ L3"},  { MPEG4_ACEP_L4, "MPEG-4 Adv Coding Efficieny @ L4"},  { MPEG4_ACP_L1, "MPEG-4 Adv Core Profile @ L1"},  { MPEG4_ACP_L2, "MPEG-4 Adv Core Profile @ L2"},  { MPEG4_AST_L1, "MPEG-4 Adv Scalable Texture @ L1"},  { MPEG4_AST_L2, "MPEG-4 Adv Scalable Texture @ L2"},  { MPEG4_AST_L3, "MPEG-4 Adv Scalable Texture @ L3"},  { MPEG4_S_STUDIO_P_L1, "MPEG-4 Simple Studio @ L1"},  { MPEG4_S_STUDIO_P_L2, "MPEG-4 Simple Studio @ L2"},  { MPEG4_S_STUDIO_P_L3, "MPEG-4 Simple Studio @ L3"},  { MPEG4_S_STUDIO_P_L4, "MPEG-4 Simple Studio @ L4"},  { MPEG4_C_STUDIO_P_L1, "MPEG-4 Core Studio @ L1"},  { MPEG4_C_STUDIO_P_L2, "MPEG-4 Core Studio @ L2"},  { MPEG4_C_STUDIO_P_L3, "MPEG-4 Core Studio @ L3"},  { MPEG4_C_STUDIO_P_L4, "MPEG-4 Core Studio @ L4"},  { MPEG4_ASP_L0, "MPEG-4 Adv Simple@L0"},  { MPEG4_ASP_L1, "MPEG-4 Adv Simple@L1"},  { MPEG4_ASP_L2, "MPEG-4 Adv Simple@L2"},  { MPEG4_ASP_L3, "MPEG-4 Adv Simple@L3"},  { MPEG4_ASP_L4, "MPEG-4 Adv Simple@L4"},  { MPEG4_ASP_L5, "MPEG-4 Adv Simple@L5"},  { MPEG4_ASP_L3B, "MPEG-4 Adv Simple@L3b"},  { MPEG4_FGSP_L0, "MPEG-4 FGS @ L0" },  { MPEG4_FGSP_L1, "MPEG-4 FGS @ L1" },  { MPEG4_FGSP_L2, "MPEG-4 FGS @ L2" },  { MPEG4_FGSP_L3, "MPEG-4 FGS @ L3" },  { MPEG4_FGSP_L4, "MPEG-4 FGS @ L4" },  { MPEG4_FGSP_L5, "MPEG-4 FGS @ L5" }};static const char *Mpeg4VisualProfileName (uint8_t visual_profile){  size_t size = sizeof(VisualProfileToName) / sizeof(*VisualProfileToName);  for (size_t ix = 0; ix < size; ix++) {    if (visual_profile == VisualProfileToName[ix].profile) {      return (VisualProfileToName[ix].name);    }  }  return (NULL);}static char* PrintVideoInfo(	MP4FileHandle mp4File,	MP4TrackId trackId){	static const u_int8_t mpegVideoTypes[] = {		MP4_MPEG2_SIMPLE_VIDEO_TYPE,	// 0x60		MP4_MPEG2_MAIN_VIDEO_TYPE,		// 0x61		MP4_MPEG2_SNR_VIDEO_TYPE,		// 0x62		MP4_MPEG2_SPATIAL_VIDEO_TYPE,	// 0x63		MP4_MPEG2_HIGH_VIDEO_TYPE,		// 0x64		MP4_MPEG2_442_VIDEO_TYPE,		// 0x65		MP4_MPEG1_VIDEO_TYPE,			// 0x6A		MP4_JPEG_VIDEO_TYPE,			// 0x6C		MP4_YUV12_VIDEO_TYPE,		MP4_H263_VIDEO_TYPE,		MP4_H261_VIDEO_TYPE,	};	static const char* mpegVideoNames[] = {		"MPEG-2 Simple",		"MPEG-2 Main",		"MPEG-2 SNR",		"MPEG-2 Spatial",		"MPEG-2 High",		"MPEG-2 4:2:2",		"MPEG-1",		"JPEG",		"YUV12",		"H.263",		"H.261",	};	u_int8_t numMpegVideoTypes =		sizeof(mpegVideoTypes) / sizeof(u_int8_t);	bool foundTypeName = false;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -