comparison mpegtsenc.c @ 5910:536e5527c1e0 libavformat

Define AVMediaType enum, and use it instead of enum CodecType, which is deprecated and will be dropped at the next major bump.
author stefano
date Tue, 30 Mar 2010 23:30:55 +0000
parents 9f349253996d
children 08cd1179a20d
comparison
equal deleted inserted replaced
5909:b8041f85c327 5910:536e5527c1e0
253 desc_length_ptr = q; 253 desc_length_ptr = q;
254 q += 2; /* patched after */ 254 q += 2; /* patched after */
255 255
256 /* write optional descriptors here */ 256 /* write optional descriptors here */
257 switch(st->codec->codec_type) { 257 switch(st->codec->codec_type) {
258 case CODEC_TYPE_AUDIO: 258 case AVMEDIA_TYPE_AUDIO:
259 if (lang && strlen(lang->value) == 3) { 259 if (lang && strlen(lang->value) == 3) {
260 *q++ = 0x0a; /* ISO 639 language descriptor */ 260 *q++ = 0x0a; /* ISO 639 language descriptor */
261 *q++ = 4; 261 *q++ = 4;
262 *q++ = lang->value[0]; 262 *q++ = lang->value[0];
263 *q++ = lang->value[1]; 263 *q++ = lang->value[1];
264 *q++ = lang->value[2]; 264 *q++ = lang->value[2];
265 *q++ = 0; /* undefined type */ 265 *q++ = 0; /* undefined type */
266 } 266 }
267 break; 267 break;
268 case CODEC_TYPE_SUBTITLE: 268 case AVMEDIA_TYPE_SUBTITLE:
269 { 269 {
270 const char *language; 270 const char *language;
271 language = lang && strlen(lang->value)==3 ? lang->value : "eng"; 271 language = lang && strlen(lang->value)==3 ? lang->value : "eng";
272 *q++ = 0x59; 272 *q++ = 0x59;
273 *q++ = 8; 273 *q++ = 8;
277 *q++ = 0x10; /* normal subtitles (0x20 = if hearing pb) */ 277 *q++ = 0x10; /* normal subtitles (0x20 = if hearing pb) */
278 put16(&q, 1); /* page id */ 278 put16(&q, 1); /* page id */
279 put16(&q, 1); /* ancillary page id */ 279 put16(&q, 1); /* ancillary page id */
280 } 280 }
281 break; 281 break;
282 case CODEC_TYPE_VIDEO: 282 case AVMEDIA_TYPE_VIDEO:
283 if (stream_type == STREAM_TYPE_VIDEO_DIRAC) { 283 if (stream_type == STREAM_TYPE_VIDEO_DIRAC) {
284 *q++ = 0x05; /*MPEG-2 registration descriptor*/ 284 *q++ = 0x05; /*MPEG-2 registration descriptor*/
285 *q++ = 4; 285 *q++ = 4;
286 *q++ = 'd'; 286 *q++ = 'd';
287 *q++ = 'r'; 287 *q++ = 'r';
422 ts_st->payload_pts = AV_NOPTS_VALUE; 422 ts_st->payload_pts = AV_NOPTS_VALUE;
423 ts_st->payload_dts = AV_NOPTS_VALUE; 423 ts_st->payload_dts = AV_NOPTS_VALUE;
424 ts_st->first_pts_check = 1; 424 ts_st->first_pts_check = 1;
425 ts_st->cc = 15; 425 ts_st->cc = 15;
426 /* update PCR pid by using the first video stream */ 426 /* update PCR pid by using the first video stream */
427 if (st->codec->codec_type == CODEC_TYPE_VIDEO && 427 if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
428 service->pcr_pid == 0x1fff) { 428 service->pcr_pid == 0x1fff) {
429 service->pcr_pid = ts_st->pid; 429 service->pcr_pid = ts_st->pid;
430 pcr_st = st; 430 pcr_st = st;
431 } 431 }
432 if (st->codec->codec_id == CODEC_ID_AAC && 432 if (st->codec->codec_id == CODEC_ID_AAC &&
460 ts->cur_pcr = av_rescale(s->max_delay, 90000, AV_TIME_BASE); 460 ts->cur_pcr = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
461 } else { 461 } else {
462 /* Arbitrary values, PAT/PMT could be written on key frames */ 462 /* Arbitrary values, PAT/PMT could be written on key frames */
463 ts->sdt_packet_period = 200; 463 ts->sdt_packet_period = 200;
464 ts->pat_packet_period = 40; 464 ts->pat_packet_period = 40;
465 if (pcr_st->codec->codec_type == CODEC_TYPE_AUDIO) { 465 if (pcr_st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
466 if (!pcr_st->codec->frame_size) { 466 if (!pcr_st->codec->frame_size) {
467 av_log(s, AV_LOG_WARNING, "frame size not set\n"); 467 av_log(s, AV_LOG_WARNING, "frame size not set\n");
468 service->pcr_packet_period = 468 service->pcr_packet_period =
469 pcr_st->codec->sample_rate/(10*512); 469 pcr_st->codec->sample_rate/(10*512);
470 } else { 470 } else {
659 /* write PES header */ 659 /* write PES header */
660 *q++ = 0x00; 660 *q++ = 0x00;
661 *q++ = 0x00; 661 *q++ = 0x00;
662 *q++ = 0x01; 662 *q++ = 0x01;
663 private_code = 0; 663 private_code = 0;
664 if (st->codec->codec_type == CODEC_TYPE_VIDEO) { 664 if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
665 if (st->codec->codec_id == CODEC_ID_DIRAC) { 665 if (st->codec->codec_id == CODEC_ID_DIRAC) {
666 *q++ = 0xfd; 666 *q++ = 0xfd;
667 } else 667 } else
668 *q++ = 0xe0; 668 *q++ = 0xe0;
669 } else if (st->codec->codec_type == CODEC_TYPE_AUDIO && 669 } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
670 (st->codec->codec_id == CODEC_ID_MP2 || 670 (st->codec->codec_id == CODEC_ID_MP2 ||
671 st->codec->codec_id == CODEC_ID_MP3)) { 671 st->codec->codec_id == CODEC_ID_MP3)) {
672 *q++ = 0xc0; 672 *q++ = 0xc0;
673 } else { 673 } else {
674 *q++ = 0xbd; 674 *q++ = 0xbd;
675 if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) { 675 if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
676 private_code = 0x20; 676 private_code = 0x20;
677 } 677 }
678 } 678 }
679 header_len = 0; 679 header_len = 0;
680 flags = 0; 680 flags = 0;
684 } 684 }
685 if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) { 685 if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) {
686 header_len += 5; 686 header_len += 5;
687 flags |= 0x40; 687 flags |= 0x40;
688 } 688 }
689 if (st->codec->codec_type == CODEC_TYPE_VIDEO && 689 if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
690 st->codec->codec_id == CODEC_ID_DIRAC) { 690 st->codec->codec_id == CODEC_ID_DIRAC) {
691 /* set PES_extension_flag */ 691 /* set PES_extension_flag */
692 pes_extension = 1; 692 pes_extension = 1;
693 flags |= 0x01; 693 flags |= 0x01;
694 694
706 len = 0; 706 len = 0;
707 *q++ = len >> 8; 707 *q++ = len >> 8;
708 *q++ = len; 708 *q++ = len;
709 val = 0x80; 709 val = 0x80;
710 /* data alignment indicator is required for subtitle data */ 710 /* data alignment indicator is required for subtitle data */
711 if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) 711 if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
712 val |= 0x04; 712 val |= 0x04;
713 *q++ = val; 713 *q++ = val;
714 *q++ = flags; 714 *q++ = flags;
715 *q++ = header_len; 715 *q++ = header_len;
716 if (pts != AV_NOPTS_VALUE) { 716 if (pts != AV_NOPTS_VALUE) {
846 buf = data; 846 buf = data;
847 size = new_size; 847 size = new_size;
848 } 848 }
849 } 849 }
850 850
851 if (st->codec->codec_type != CODEC_TYPE_AUDIO) { 851 if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
852 // for video and subtitle, write a single pes packet 852 // for video and subtitle, write a single pes packet
853 mpegts_write_pes(s, st, buf, size, pts, dts); 853 mpegts_write_pes(s, st, buf, size, pts, dts);
854 av_free(data); 854 av_free(data);
855 return 0; 855 return 0;
856 } 856 }