comparison flvdec.c @ 5097:453175c733c4 libavformat

flvdec: expose metadata through the generic metadata API original patch from Art Clarke aclarke _at_ xuggle _dot_ com
author aurel
date Mon, 06 Jul 2009 21:54:37 +0000
parents 7edb10e8f03b
children 44a0fab134a9
comparison
equal deleted inserted replaced
5096:7edb10e8f03b 5097:453175c733c4
22 * You should have received a copy of the GNU Lesser General Public 22 * You should have received a copy of the GNU Lesser General Public
23 * License along with FFmpeg; if not, write to the Free Software 23 * License along with FFmpeg; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 */ 25 */
26 26
27 #include "libavutil/avstring.h"
27 #include "libavcodec/bytestream.h" 28 #include "libavcodec/bytestream.h"
28 #include "libavcodec/mpeg4audio.h" 29 #include "libavcodec/mpeg4audio.h"
29 #include "avformat.h" 30 #include "avformat.h"
30 #include "flv.h" 31 #include "flv.h"
31 32
216 if(depth == 1 && key) { //only look for metadata values when we are not nested and key != NULL 217 if(depth == 1 && key) { //only look for metadata values when we are not nested and key != NULL
217 acodec = astream ? astream->codec : NULL; 218 acodec = astream ? astream->codec : NULL;
218 vcodec = vstream ? vstream->codec : NULL; 219 vcodec = vstream ? vstream->codec : NULL;
219 220
220 if(amf_type == AMF_DATA_TYPE_BOOL) { 221 if(amf_type == AMF_DATA_TYPE_BOOL) {
222 av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val));
223 av_metadata_set(&s->metadata, key, str_val);
221 } else if(amf_type == AMF_DATA_TYPE_NUMBER) { 224 } else if(amf_type == AMF_DATA_TYPE_NUMBER) {
225 snprintf(str_val, sizeof(str_val), "%.f", num_val);
226 av_metadata_set(&s->metadata, key, str_val);
222 if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE; 227 if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE;
223 else if(!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0)) 228 else if(!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0))
224 vcodec->bit_rate = num_val * 1024.0; 229 vcodec->bit_rate = num_val * 1024.0;
225 } 230 } else if (amf_type == AMF_DATA_TYPE_STRING)
231 av_metadata_set(&s->metadata, key, str_val);
226 } 232 }
227 233
228 return 0; 234 return 0;
229 } 235 }
230 236