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

📄 hint_track.c

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 C
📖 第 1 页 / 共 3 页
字号:
}static void AddSDPLine(GF_List *list, char *sdp_text, Bool is_movie_sdp){	const char *sdp_order;	u32 i, count = gf_list_count(list);	char fc = sdp_text[0];	sdp_order = (is_movie_sdp) ? "vosiuepcbzkatr" : "micbka";	for (i=0; i<count; i++) {		char *l = (char *)gf_list_get(list, i);		char *s1 = (char *)strchr(sdp_order, l[0]);		char *s2 = (char *)strchr(sdp_order, fc);		if (s1 && s2 && (strlen(s2)>strlen(s1))) {			gf_list_insert(list, sdp_text, i);			return;		}	}	gf_list_add(list, sdp_text);}static void ReorderSDP(char *sdp_text, Bool is_movie_sdp){	char *cur, b;	GF_List *lines = gf_list_new();	cur = sdp_text;	while (cur) {		char *st = strstr(cur, "\r\n");		assert(st);		st += 2;		if (!st[0]) {			AddSDPLine(lines, strdup(cur), is_movie_sdp);			break;		}		b = st[0];		st[0] = 0;		AddSDPLine(lines, strdup(cur), is_movie_sdp);		st[0] = b;		cur = st;	}	strcpy(sdp_text, "");	while (gf_list_count(lines)) {		char *cur = (char *)gf_list_get(lines, 0);		gf_list_rem(lines, 0);		strcat(sdp_text, cur);		free(cur);	}	gf_list_del(lines);}//add an SDP line to the SDP container at the track level (media-specific SDP info)GF_Err gf_isom_sdp_add_track_line(GF_ISOFile *the_file, u32 trackNumber, const char *text){	GF_TrackBox *trak;	GF_UserDataMap *map;	GF_HintTrackInfoBox *hnti;	GF_SDPBox *sdp;	GF_Err e;	char *buf;	trak = gf_isom_get_track_from_file(the_file, trackNumber);	if (!trak) return GF_BAD_PARAM;	//currently, only RTP hinting supports SDP	if (!CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM;	map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HNTI, NULL);	if (!map) return GF_ISOM_INVALID_FILE;	//we should have only one HNTI in the UDTA	if (gf_list_count(map->boxList) != 1) return GF_ISOM_INVALID_FILE;	hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxList, 0);	if (!hnti->SDP) {		e = hnti_AddBox(hnti, gf_isom_box_new(GF_ISOM_BOX_TYPE_SDP));		if (e) return e;	}	sdp = (GF_SDPBox *) hnti->SDP;	if (!sdp->sdpText) {		sdp->sdpText = (char *)malloc(sizeof(char) * (strlen(text) + 3));		strcpy(sdp->sdpText, text);		strcat(sdp->sdpText, "\r\n");		return GF_OK;	}	buf = (char *)malloc(sizeof(char) * (strlen(sdp->sdpText) + strlen(text) + 3));	strcpy(buf, sdp->sdpText);	strcat(buf, text);	strcat(buf, "\r\n");	free(sdp->sdpText);	ReorderSDP(buf, 0);	sdp->sdpText = buf;		return GF_OK;}//remove all SDP info at the track levelGF_Err gf_isom_sdp_clean_track(GF_ISOFile *the_file, u32 trackNumber){	GF_TrackBox *trak;	GF_UserDataMap *map;	GF_HintTrackInfoBox *hnti;	trak = gf_isom_get_track_from_file(the_file, trackNumber);	if (!trak) return GF_BAD_PARAM;	//currently, only RTP hinting supports SDP	if (!CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM;	map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HNTI, NULL);	if (!map) return GF_ISOM_INVALID_FILE;	//we should have only one HNTI in the UDTA	if (gf_list_count(map->boxList) != 1) return GF_ISOM_INVALID_FILE;	hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxList, 0);	if (!hnti->SDP) return GF_OK;	//and free the SDP	free(((GF_SDPBox *)hnti->SDP)->sdpText);	((GF_SDPBox *)hnti->SDP)->sdpText = NULL;	return GF_OK;}//add an SDP line to the SDP container at the movie level (presentation SDP info)//NOTE: the \r\n end of line for SDP is automatically insertedGF_Err gf_isom_sdp_add_line(GF_ISOFile *movie, const char *text){	GF_UserDataMap *map;	GF_RTPBox *rtp;	GF_Err e;	GF_HintTrackInfoBox *hnti;	char *buf;	if (!movie->moov) return GF_BAD_PARAM;	//check if we have a udta ...	if (!movie->moov->udta) {		e = moov_AddBox((GF_Box*)movie->moov, gf_isom_box_new(GF_ISOM_BOX_TYPE_UDTA));		if (e) return e;	}	//find a hnti in the udta	map = udta_getEntry(movie->moov->udta, GF_ISOM_BOX_TYPE_HNTI, NULL);	if (!map) {		e = udta_AddBox(movie->moov->udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HNTI));		if (e) return e;		map = udta_getEntry(movie->moov->udta, GF_ISOM_BOX_TYPE_HNTI, NULL);	}	//there should be one and only one hnti	if (!gf_list_count(map->boxList) ) {		e = udta_AddBox(movie->moov->udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HNTI));		if (e) return e;	}	else if (gf_list_count(map->boxList) < 1) return GF_ISOM_INVALID_FILE;	hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxList, 0);	if (!hnti->SDP) {		//we have to create it by hand, as we have a duplication of box type 		//(GF_RTPSampleEntryBox and GF_RTPBox have the same type...)		rtp = (GF_RTPBox *) malloc(sizeof(GF_RTPBox));		rtp->subType = GF_ISOM_BOX_TYPE_SDP;		rtp->type = GF_ISOM_BOX_TYPE_RTP;		rtp->sdpText = NULL;		hnti_AddBox(hnti, (GF_Box *)rtp);	}	rtp = (GF_RTPBox *) hnti->SDP;	if (!rtp->sdpText) {		rtp->sdpText = (char*)malloc(sizeof(char) * (strlen(text) + 3));		strcpy(rtp->sdpText, text);		strcat(rtp->sdpText, "\r\n");		return GF_OK;	}	buf = (char*)malloc(sizeof(char) * (strlen(rtp->sdpText) + strlen(text) + 3));	strcpy(buf, rtp->sdpText);	strcat(buf, text);	strcat(buf, "\r\n");	free(rtp->sdpText);	ReorderSDP(buf, 1);	rtp->sdpText = buf;		return GF_OK;}//remove all SDP info at the movie levelGF_Err gf_isom_sdp_clean(GF_ISOFile *movie){	GF_UserDataMap *map;	GF_HintTrackInfoBox *hnti;	//check if we have a udta ...	if (!movie->moov || !movie->moov->udta) return GF_OK;	//find a hnti in the udta	map = udta_getEntry(movie->moov->udta, GF_ISOM_BOX_TYPE_HNTI, NULL);	if (!map) return GF_OK;	//there should be one and only one hnti	if (gf_list_count(map->boxList) != 1) return GF_ISOM_INVALID_FILE;	hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxList, 0);	//remove and destroy the entry	gf_list_rem(map->boxList, 0);	gf_isom_box_del((GF_Box *)hnti);	return GF_OK;}#endif //GPAC_READ_ONLYGF_EXPORTGF_Err gf_isom_sdp_get(GF_ISOFile *movie, const char **sdp, u32 *length){	GF_UserDataMap *map;	GF_HintTrackInfoBox *hnti;	GF_RTPBox *rtp;	*length = 0;	*sdp = NULL;	if (!movie || !movie->moov) return GF_BAD_PARAM;	//check if we have a udta ...	if (!movie->moov->udta) return GF_OK;	//find a hnti in the udta	map = udta_getEntry(movie->moov->udta, GF_ISOM_BOX_TYPE_HNTI, NULL);	if (!map) return GF_OK;	//there should be one and only one hnti	if (gf_list_count(map->boxList) != 1) return GF_ISOM_INVALID_FILE;	hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxList, 0);	if (!hnti->SDP) return GF_OK;	rtp = (GF_RTPBox *) hnti->SDP;	*length = strlen(rtp->sdpText);	*sdp = rtp->sdpText;	return GF_OK;}GF_EXPORTGF_Err gf_isom_sdp_track_get(GF_ISOFile *the_file, u32 trackNumber, const char **sdp, u32 *length){	GF_TrackBox *trak;	GF_UserDataMap *map;	GF_HintTrackInfoBox *hnti;	GF_SDPBox *sdpa;	*sdp = NULL;	*length = 0;	trak = gf_isom_get_track_from_file(the_file, trackNumber);	if (!trak) return GF_BAD_PARAM;	if (!trak->udta) return GF_OK;	map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HNTI, NULL);	if (!map) return GF_ISOM_INVALID_FILE;	//we should have only one HNTI in the UDTA	if (gf_list_count(map->boxList) != 1) return GF_ISOM_INVALID_FILE;	hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxList, 0);	if (!hnti->SDP) return GF_OK;	sdpa = (GF_SDPBox *) hnti->SDP;	*length = strlen(sdpa->sdpText);	*sdp = sdpa->sdpText;	return GF_OK;}GF_EXPORTu32 gf_isom_get_payt_count(GF_ISOFile *the_file, u32 trackNumber){	u32 i, count;	GF_TrackBox *trak;	GF_UserDataMap *map;	GF_HintInfoBox *hinf;	GF_PAYTBox *payt;	trak = gf_isom_get_track_from_file(the_file, trackNumber);	if (!trak) return 0;	if (!CheckHintFormat(trak, GF_4CC('r', 't', 'p', ' '))) return 0;	map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HINF, NULL);	if (!map) return 0;	if (gf_list_count(map->boxList) != 1) return 0;	hinf = (GF_HintInfoBox *)gf_list_get(map->boxList, 0);	count = 0;	i = 0;	while ((payt = gf_list_enum(hinf->boxList, &i))) {		if (payt->type == GF_ISOM_BOX_TYPE_PAYT) count++;	}	return count;}GF_EXPORTconst char *gf_isom_get_payt_info(GF_ISOFile *the_file, u32 trackNumber, u32 index, u32 *payID){	u32 i, count;	GF_TrackBox *trak;	GF_UserDataMap *map;	GF_HintInfoBox *hinf;	GF_PAYTBox *payt;	trak = gf_isom_get_track_from_file(the_file, trackNumber);	if (!trak || !index) return NULL;	if (!CheckHintFormat(trak, GF_4CC('r', 't', 'p', ' '))) return NULL;	map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HINF, NULL);	if (!map) return NULL;	if (gf_list_count(map->boxList) != 1) return NULL;	hinf = (GF_HintInfoBox *)gf_list_get(map->boxList, 0);	count = 0;	i = 0;	while ((payt = gf_list_enum(hinf->boxList, &i))) {		if (payt->type == GF_ISOM_BOX_TYPE_PAYT) {			count++;			if (count == index) {				if (payID) *payID=payt->payloadCode;				return payt->payloadString;			}		}	}	return NULL;}

⌨️ 快捷键说明

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