|
static struct ast_frame * | create_video_frame (uint8_t *start, uint8_t *end, int format, int head, struct ast_frame *prev) |
|
static struct video_dec_desc * | dec_init (uint32_t the_ast_format) |
|
static struct video_dec_desc * | dec_uninit (struct video_dec_desc *v) |
| uninitialize the descriptor for remote video stream More...
|
|
static int | fbuf_append (struct fbuf_t *b, uint8_t *src, int len, int sbit, int ebit) |
|
static int | ffmpeg_decode (struct video_dec_desc *v, struct fbuf_t *b) |
|
static int | ffmpeg_encode (struct video_out_desc *v) |
|
static int | h261_decap (struct fbuf_t *b, uint8_t *data, int len) |
|
static int | h261_enc_init (AVCodecContext *enc_ctx) |
|
static struct ast_frame * | h261_encap (struct fbuf_t *b, int mtu, struct ast_frame **tail) |
|
static int | h263_decap (struct fbuf_t *b, uint8_t *data, int len) |
|
static int | h263_enc_init (AVCodecContext *enc_ctx) |
|
static struct ast_frame * | h263_encap (struct fbuf_t *b, int mtu, struct ast_frame **tail) |
|
static int | h263p_decap (struct fbuf_t *b, uint8_t *data, int len) |
| extract the bitstream from the RTP payload. This is format dependent. For h263+, the format is defined in RFC 2429 and basically has a fixed 2-byte header as follows: 5 bits RR reserved, shall be 0 1 bit P indicate a start/end condition, in which case the payload should be prepended by two zero-valued bytes. 1 bit V there is an additional VRC header after this header 6 bits PLEN length in bytes of extra picture header 3 bits PEBIT how many bits to be ignored in the last byte More...
|
|
static int | h263p_enc_init (AVCodecContext *enc_ctx) |
| initialization of h263p More...
|
|
static struct ast_frame * | h263p_encap (struct fbuf_t *b, int mtu, struct ast_frame **tail) |
|
static int | h264_dec_init (AVCodecContext *dec_ctx) |
|
static int | h264_decap (struct fbuf_t *b, uint8_t *data, int len) |
|
static int | h264_enc_init (AVCodecContext *enc_ctx) |
|
static struct ast_frame * | h264_encap (struct fbuf_t *b, int mtu, struct ast_frame **tail) |
|
static struct video_codec_desc * | map_video_codec (int fmt) |
|
static enum CodecID | map_video_format (uint32_t ast_format, int rw) |
| map an asterisk format into an ffmpeg one More...
|
|
static int | mpeg4_decap (struct fbuf_t *b, uint8_t *data, int len) |
|
static int | mpeg4_decode (struct video_dec_desc *v, struct fbuf_t *b) |
|
static int | mpeg4_enc_init (AVCodecContext *enc_ctx) |
|
static struct ast_frame * | mpeg4_encap (struct fbuf_t *b, int mtu, struct ast_frame **tail) |
|
static struct ast_frame * create_video_frame |
( |
uint8_t * |
start, |
|
|
uint8_t * |
end, |
|
|
int |
format, |
|
|
int |
head, |
|
|
struct ast_frame * |
prev |
|
) |
| |
|
static |
Build an ast_frame for a given chunk of data, and link it into the queue, with possibly 'head' bytes at the beginning to fill in some fields later.
Definition at line 228 of file vcodecs.c.
230{
232 uint8_t *data;
234
240 if (f)
245 }
249
250
261
262 if (prev)
264
265 return f;
266}
#define ast_calloc(num, len)
A wrapper for calloc()
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@226 data
enum ast_frame_type frametype
References ast_calloc, AST_FRAME_VIDEO, ast_free, AST_LIST_NEXT, ast_log, AST_MALLOCD_DATA, AST_MALLOCD_HDR, ast_frame::data, ast_frame::datalen, ast_frame::delivery, end, ast_frame::frametype, len(), LOG_WARNING, ast_frame::mallocd, NULL, ast_frame::offset, ast_frame::ptr, ast_frame::samples, ast_frame::seqno, ast_frame::src, and ast_frame::subclass.
Referenced by h261_encap(), h263_encap(), h263p_encap(), h264_encap(), and mpeg4_encap().
Definition at line 1204 of file vcodecs.c.
1205{
1206 enum CodecID codec;
1210
1212
1217 }
1218
1220
1225 }
1226
1227
1228
1229 v->
dec_ctx = avcodec_alloc_context();
1233 }
1234
1240 }
1241
1246 }
1247
1248 v->
d_frame = avcodec_alloc_frame();
1252 }
1255
1256 return v;
1257}
struct fbuf_t * dec_in_cur
AVCodecParserContext * parser
struct video_codec_desc * d_callbacks
struct fbuf_t * dec_in_dpy
struct fbuf_t dec_in[N_DEC_IN]
static enum CodecID map_video_format(uint32_t ast_format, int rw)
map an asterisk format into an ffmpeg one
static struct video_codec_desc * map_video_codec(int fmt)
static struct video_dec_desc * dec_uninit(struct video_dec_desc *v)
uninitialize the descriptor for remote video stream
References ast_calloc, ast_log, video_dec_desc::codec, video_dec_desc::d_callbacks, video_dec_desc::d_frame, video_dec_desc::dec_ctx, video_dec_desc::dec_in, video_dec_desc::dec_in_cur, video_dec_desc::dec_in_dpy, dec_uninit(), video_dec_desc::discard, video_codec_desc::format, LOG_WARNING, map_video_codec(), map_video_format(), NULL, and video_dec_desc::parser.
static int fbuf_append |
( |
struct fbuf_t * |
b, |
|
|
uint8_t * |
src, |
|
|
int |
len, |
|
|
int |
sbit, |
|
|
int |
ebit |
|
) |
| |
|
static |
Definition at line 273 of file vcodecs.c.
275{
276
277
278
279
280 int need =
len + FF_INPUT_BUFFER_PADDING_SIZE;
281 int i;
282 uint8_t *dst, mask;
283
284 if (
b->data ==
NULL) {
289 }
else if (
b->used + need >
b->size) {
290 b->size =
b->used + need;
292 }
293 if (
b->data ==
NULL) {
296 return 1;
297 }
298 if (
b->used == 0 &&
b->ebit != 0) {
301 }
302 dst =
b->data +
b->used;
304 if (i == 0) {
305
306 } else if (i == 8) {
307 mask = (1 <<
b->ebit) - 1;
308
309 dst[-1] &= ~mask;
310 dst[-1] |= (*src & mask);
311 src += 1;
313 } else {
315 b->ebit, sbit,
b->used);
316 return 1;
317 }
318 memcpy(dst, src,
len);
321 b->data[
b->used] = 0;
322 return 0;
323}
#define ast_realloc(p, len)
A wrapper for realloc()
References ast_calloc, ast_log, ast_realloc, b, len(), LOG_WARNING, NULL, and ast_frame::src.
Referenced by h261_decap(), h263_decap(), h263p_decap(), h264_decap(), and mpeg4_decap().
Definition at line 729 of file vcodecs.c.
731{
732 uint8_t *
d =
b->data;
733 int start = 0, i,
len =
b->used;
735 const int pheader_len = 4;
736 uint8_t h261_hdr[4];
737 uint8_t *h = h261_hdr;
738 int sbit = 0, ebit = 0;
739
740#define H261_MIN_LEN 10
743
744 memset(h261_hdr, '\0', sizeof(h261_hdr));
745
746
747
748
749
750
751 for (i =
H261_MIN_LEN, start = 0; start <
len - 1; start = i, i += 4) {
752#if 0
754#else
755 int found = 0, found_ebit = 0;
756 for (; i <
len ; i++) {
757 uint8_t x, rpos, lpos;
759 continue;
761 if (x == 0)
762 continue;
763
764
765
766
767
768 for (rpos = 0x80, ebit = 7; rpos; ebit--, rpos >>= 1)
769 if (x & rpos)
770 break;
772 for (lpos = (rpos >> 1); lpos ; lpos >>= 1)
773 if (x & lpos)
774 break;
775 if (lpos)
776 continue;
777
778
779
780 if (i - start > mtu)
781 break;
782 found_ebit = ebit;
783 found = i;
784 i += 4;
785 }
788 ebit = 0;
789 }
790 if (i - start > mtu && found) {
791
792 i = found;
793 ebit = found_ebit;
794 }
795#endif
796 if (i - start < 4)
797 continue;
798
799
800
802 pheader_len, cur);
803
804 if (!f)
805 break;
806
807 h[0] = ( (sbit & 7) << 5 ) | ( (ebit & 7) << 2 ) | 1;
809 if (ebit)
810 i--;
811 sbit = (8 - ebit) & 7;
812 ebit = 0;
813 if (!cur)
815 cur = f;
816 }
817 if (cur)
819
820 *tail = cur;
822}
struct sla_ringing_trunk * first
static struct ast_frame * create_video_frame(uint8_t *start, uint8_t *end, int format, int head, struct ast_frame *prev)
References AST_FORMAT_H261, b, create_video_frame(), d, ast_frame::data, first, H261_MIN_LEN, len(), NULL, ast_frame::ptr, and ast_frame::subclass.
Definition at line 575 of file vcodecs.c.
577{
578 uint8_t *
d =
b->data;
579 int start = 0, i,
len =
b->used;
581 const int pheader_len = 4;
582 uint8_t h263_hdr[12];
583 uint8_t *h = h263_hdr;
584
585#define H263_MIN_LEN 6
588
589 memset(h263_hdr, '\0', sizeof(h263_hdr));
590
591
592
593
594
595
596
597
598
599
600
601
602 h[1] = ( (
d[4] & 0x1f) << 3 ) |
603 ( (
d[5] & 0xc0) >> 5 );
604
605
606
607
608
610
611 for (; i <
len ; i++) {
612 uint8_t x, rpos, lpos;
613 int rpos_i;
615 continue;
617 break;
619 if (x == 0)
620 continue;
621
622
623
624
625
626 for (rpos = 0x80, rpos_i = 8; rpos; rpos >>= 1, rpos_i--)
627 if (x & rpos)
628 break;
630 for (lpos = rpos; lpos ; lpos >>= 1)
631 if (x & lpos)
632 break;
633 if (lpos)
634 continue;
635
636
637
638 if (rpos == 0x80) {
639 i = i - 1;
640 } else {
642 rpos, rpos_i);
643 }
644 break;
645 }
646
647
648
650 pheader_len, cur);
651
652 if (!f)
653 break;
655
656
657
658 if (!cur)
660 cur = f;
661 }
662
663 if (cur)
665
666 *tail = cur;
668}
References AST_FORMAT_H263, ast_log, b, create_video_frame(), d, ast_frame::data, first, H263_MIN_LEN, len(), LOG_WARNING, NULL, ast_frame::ptr, and ast_frame::subclass.
static int h263p_decap |
( |
struct fbuf_t * |
b, |
|
|
uint8_t * |
data, |
|
|
int |
len |
|
) |
| |
|
static |
extract the bitstream from the RTP payload. This is format dependent. For h263+, the format is defined in RFC 2429 and basically has a fixed 2-byte header as follows: 5 bits RR reserved, shall be 0 1 bit P indicate a start/end condition, in which case the payload should be prepended by two zero-valued bytes. 1 bit V there is an additional VRC header after this header 6 bits PLEN length in bytes of extra picture header 3 bits PEBIT how many bits to be ignored in the last byte
XXX the code below is not complete.
Definition at line 433 of file vcodecs.c.
434{
435 int PLEN;
436
439 return 1;
440 }
441 PLEN = ( (data[0] & 1) << 5 ) | ( (data[1] & 0xf8) >> 3);
442
443 if (PLEN > 0) {
444 data += PLEN;
446 }
447 if (data[0] & 4)
448 data[0] = data[1] = 0;
449 else {
450 data += 2;
452 }
454}
References ast_log, b, ast_frame::data, fbuf_append(), len(), and LOG_WARNING.
Definition at line 360 of file vcodecs.c.
362{
364 uint8_t *
d =
b->data;
367
368 for (;
len > 0;
len -= l,
d += l) {
371 int i, h;
372
373 if (
len >= 3 &&
d[0] == 0 &&
d[1] == 0 &&
d[2] >= 0x80) {
374
375 for (i = 3; i <
len - 3; i++) {
376 if (
d[i] == 0 &&
d[i+1] == 0 &&
d[i+2] >= 0x80) {
377 l = i;
378 break;
379 }
380 }
381 }
382 if (l > mtu || l >
len) {
384 }
385 if (l < 1 || l > mtu) {
387 break;
388 }
389
390 if (
d[0] == 0 &&
d[1] == 0) {
391 h = 0;
392 } else {
393 h = 2;
394 }
395
397 if (!f)
398 break;
399
401 if (h == 0) {
403 } else {
405 }
406
407 if (!cur)
409 cur = f;
410 }
411
412 if (cur)
414
415 *tail = cur;
417}
References ast_log, b, create_video_frame(), d, ast_frame::data, first, len(), LOG_WARNING, MIN, NULL, ast_frame::ptr, and ast_frame::subclass.
Definition at line 959 of file vcodecs.c.
961{
963 uint8_t *
d, *start =
b->data;
964 uint8_t *
end = start +
b->used;
965
966
967
968
969#define HAVE_NAL(x) (x[-4] == 0 && x[-3] == 0 && x[-2] == 0 && x[-1] == 1)
970 for (start += 4; start <
end; start++) {
971 int ty = start[0] & 0x1f;
972 if (
HAVE_NAL(start) && ty != 0 && ty != 31)
973 break;
974 }
975
976
977
978
979
980 for (;start <
end - 4; start =
d) {
981 int size;
982 uint8_t hdr[2];
983 int ty = 0;
984
985
986 for (
d = start + 4;
d <
end;
d++) {
989 break;
990 }
991
994 } else if (ty == 0 || ty == 31) {
996 ty,
d - (uint8_t *)
b->data,
b->used);
997 continue;
998 }
999
1000 size =
d - start - 4;
1001
1002 if (size < mtu) {
1003
1005 if (!f)
1006 break;
1009
1010 cur = f;
1011 continue;
1012 }
1013
1014
1015 hdr[0] = (*start & 0xe0) | 28;
1016 hdr[1] = (*start++ & 0x1f) | 0x80 ;
1017 size--;
1018 while (size) {
1020 int frag_size =
MIN(size, mtu);
1021
1023 if (!f)
1024 break;
1025 size -= frag_size;
1026 start += frag_size;
1027
1030 data[1] = hdr[1] | (size == 0 ? 0x40 : 0);
1031 hdr[1] &= ~0x80;
1034 cur = f;
1035 }
1036 }
1037
1038 if (cur)
1040
1041 *tail = cur;
1042
1044}
References AST_FORMAT_H264, ast_log, b, create_video_frame(), d, ast_frame::data, end, first, HAVE_NAL, LOG_WARNING, MIN, NULL, ast_frame::ptr, and ast_frame::subclass.