You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	use new metadata API in rm (de)muxer
Originally committed as revision 17396 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
		| @@ -155,8 +155,8 @@ OBJS-$(CONFIG_RAWVIDEO_DEMUXER)          += raw.o | ||||
| OBJS-$(CONFIG_RAWVIDEO_MUXER)            += raw.o | ||||
| OBJS-$(CONFIG_REDIR_DEMUXER)             += rtsp.o | ||||
| OBJS-$(CONFIG_RL2_DEMUXER)               += rl2.o | ||||
| OBJS-$(CONFIG_RM_DEMUXER)                += rmdec.o | ||||
| OBJS-$(CONFIG_RM_MUXER)                  += rmenc.o | ||||
| OBJS-$(CONFIG_RM_DEMUXER)                += rmdec.o rm.o | ||||
| OBJS-$(CONFIG_RM_MUXER)                  += rmenc.o rm.o | ||||
| OBJS-$(CONFIG_ROQ_DEMUXER)               += idroq.o | ||||
| OBJS-$(CONFIG_ROQ_MUXER)                 += raw.o | ||||
| OBJS-$(CONFIG_RPL_DEMUXER)               += rpl.o | ||||
|   | ||||
							
								
								
									
										29
									
								
								libavformat/rm.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								libavformat/rm.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| /* | ||||
|  * "Real" compatible muxer and demuxer common code. | ||||
|  * Copyright (c) 2009  Aurelien Jacobs <aurel@gnuage.org> | ||||
|  * | ||||
|  * This file is part of FFmpeg. | ||||
|  * | ||||
|  * FFmpeg is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * FFmpeg is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with FFmpeg; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||
|  */ | ||||
|  | ||||
| #include "rm.h" | ||||
|  | ||||
| const char *ff_rm_metadata[4] = { | ||||
|     "title", | ||||
|     "author", | ||||
|     "copyright", | ||||
|     "comment" | ||||
| }; | ||||
| @@ -24,6 +24,8 @@ | ||||
|  | ||||
| #include "avformat.h" | ||||
|  | ||||
| extern const char *ff_rm_metadata[4]; | ||||
|  | ||||
| typedef struct RMStream RMStream; | ||||
|  | ||||
| RMStream *ff_rm_alloc_rmstream (void); | ||||
|   | ||||
| @@ -72,6 +72,17 @@ static void get_str8(ByteIOContext *pb, char *buf, int buf_size) | ||||
|     get_strl(pb, buf, buf_size, get_byte(pb)); | ||||
| } | ||||
|  | ||||
| static void rm_read_metadata(AVFormatContext *s, int wide) | ||||
| { | ||||
|     char buf[1024]; | ||||
|     int i; | ||||
|     for (i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) { | ||||
|         int len = wide ? get_be16(s->pb) : get_byte(s->pb); | ||||
|         get_strl(s->pb, buf, sizeof(buf), len); | ||||
|         av_metadata_set(&s->metadata, ff_rm_metadata[i], buf); | ||||
|     } | ||||
| } | ||||
|  | ||||
| RMStream *ff_rm_alloc_rmstream (void) | ||||
| { | ||||
|     RMStream *rms = av_mallocz(sizeof(RMStream)); | ||||
| @@ -95,10 +106,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb, | ||||
|     if (((version >> 16) & 0xff) == 3) { | ||||
|         int64_t startpos = url_ftell(pb); | ||||
|         url_fskip(pb, 14); | ||||
|         get_str8(pb, s->title, sizeof(s->title)); | ||||
|         get_str8(pb, s->author, sizeof(s->author)); | ||||
|         get_str8(pb, s->copyright, sizeof(s->copyright)); | ||||
|         get_str8(pb, s->comment, sizeof(s->comment)); | ||||
|         rm_read_metadata(s, 0); | ||||
|         if ((startpos + (version & 0xffff)) >= url_ftell(pb) + 2) { | ||||
|             // fourcc (should always be "lpcJ") | ||||
|             get_byte(pb); | ||||
| @@ -213,11 +221,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb, | ||||
|             get_byte(pb); | ||||
|             get_byte(pb); | ||||
|             get_byte(pb); | ||||
|  | ||||
|             get_str8(pb, s->title, sizeof(s->title)); | ||||
|             get_str8(pb, s->author, sizeof(s->author)); | ||||
|             get_str8(pb, s->copyright, sizeof(s->copyright)); | ||||
|             get_str8(pb, s->comment, sizeof(s->comment)); | ||||
|             rm_read_metadata(s, 0); | ||||
|         } | ||||
|     } | ||||
|     return 0; | ||||
| @@ -364,10 +368,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) | ||||
|             flags = get_be16(pb); /* flags */ | ||||
|             break; | ||||
|         case MKTAG('C', 'O', 'N', 'T'): | ||||
|             get_str16(pb, s->title, sizeof(s->title)); | ||||
|             get_str16(pb, s->author, sizeof(s->author)); | ||||
|             get_str16(pb, s->copyright, sizeof(s->copyright)); | ||||
|             get_str16(pb, s->comment, sizeof(s->comment)); | ||||
|             rm_read_metadata(s, 1); | ||||
|             break; | ||||
|         case MKTAG('M', 'D', 'P', 'R'): | ||||
|             st = av_new_stream(s, 0); | ||||
|   | ||||
| @@ -70,6 +70,7 @@ static void rv10_write_header(AVFormatContext *ctx, | ||||
|     const char *desc, *mimetype; | ||||
|     int nb_packets, packet_total_size, packet_max_size, size, packet_avg_size, i; | ||||
|     int bit_rate, v, duration, flags, data_pos; | ||||
|     AVMetadataTag *tag; | ||||
|  | ||||
|     start_ptr = s->buf_ptr; | ||||
|  | ||||
| @@ -123,14 +124,17 @@ static void rv10_write_header(AVFormatContext *ctx, | ||||
|     /* comments */ | ||||
|  | ||||
|     put_tag(s,"CONT"); | ||||
|     size = strlen(ctx->title) + strlen(ctx->author) + strlen(ctx->copyright) + | ||||
|         strlen(ctx->comment) + 4 * 2 + 10; | ||||
|     size =  4 * 2 + 10; | ||||
|     for(i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) { | ||||
|         tag = av_metadata_get(ctx->metadata, ff_rm_metadata[i], NULL, 0); | ||||
|         if(tag) size += strlen(tag->value); | ||||
|     } | ||||
|     put_be32(s,size); | ||||
|     put_be16(s,0); | ||||
|     put_str(s, ctx->title); | ||||
|     put_str(s, ctx->author); | ||||
|     put_str(s, ctx->copyright); | ||||
|     put_str(s, ctx->comment); | ||||
|     for(i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) { | ||||
|         tag = av_metadata_get(ctx->metadata, ff_rm_metadata[i], NULL, 0); | ||||
|         put_str(s, tag ? tag->value : ""); | ||||
|     } | ||||
|  | ||||
|     for(i=0;i<ctx->nb_streams;i++) { | ||||
|         int codec_data_size; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user