- Timestamp:
- Feb 28, 2011 6:59:47 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_stream.c
r3420 r3425 85 85 pjmedia_endpt *endpt; /**< Media endpoint. */ 86 86 pjmedia_vid_codec_mgr *codec_mgr; /**< Codec manager. */ 87 pjmedia_vid_stream_info info; /**< Stream info. */ 87 88 88 89 pjmedia_vid_channel *enc; /**< Encoding channel. */ … … 129 130 130 131 #if TRACE_JB 131 pj_oshandle_t trace_jb_fd;/**< Jitter tracing file handle.*/132 char *trace_jb_buf;/**< Jitter tracing buffer. */132 pj_oshandle_t trace_jb_fd; /**< Jitter tracing file handle.*/ 133 char *trace_jb_buf; /**< Jitter tracing buffer. */ 133 134 #endif 134 135 135 pjmedia_vid_codec *codec; /**< Codec instance being used. */ 136 pjmedia_vid_codec_info codec_info; /**< Codec param. */ 137 pjmedia_vid_codec_param codec_param; /**< Codec param. */ 138 139 pjmedia_vid_stream_info info; 136 pjmedia_vid_codec *codec; /**< Codec instance being used. */ 140 137 }; 141 138 … … 627 624 status = pjmedia_jbuf_reset(stream->jb); 628 625 PJ_LOG(4,(channel->port.info.name.ptr, "Jitter buffer reset")); 629 630 626 } else { 631 632 /* Video stream */633 634 627 /* Just put the payload into jitter buffer */ 635 628 pjmedia_jbuf_put_frame3(stream->jb, payload, payloadlen, 0, … … 928 921 if (frame->bit_info & PJMEDIA_VID_CODEC_EVENT_FMT_CHANGED) { 929 922 /* Update param from codec */ 930 stream->codec->op->get_param(stream->codec, &stream->codec_param);923 stream->codec->op->get_param(stream->codec, stream->info.codec_param); 931 924 932 925 /* Update decoding channel port info */ 933 stream->dec->port.info.fmt = stream->codec_param.dec_fmt; 926 pjmedia_format_copy(&stream->dec->port.info.fmt, 927 &stream->info.codec_param->dec_fmt); 934 928 } 935 929 … … 965 959 /* Init vars */ 966 960 if (dir==PJMEDIA_DIR_DECODING) { 967 type_name = "vst rmdec";961 type_name = "vstdec"; 968 962 fmt = &info->codec_param->dec_fmt; 969 963 } else { 970 type_name = "vst rmenc";964 type_name = "vstenc"; 971 965 fmt = &info->codec_param->enc_fmt; 972 966 } … … 1054 1048 PJ_ASSERT_RETURN(stream != NULL, PJ_ENOMEM); 1055 1049 1050 /* Copy stream info */ 1051 pj_memcpy(&stream->info, info, sizeof(*info)); 1052 1056 1053 /* Get codec manager */ 1057 1054 stream->codec_mgr = pjmedia_vid_codec_mgr_instance(); … … 1064 1061 1065 1062 /* Create and initialize codec: */ 1066 stream->codec_info = info->codec_info;1067 1063 status = pjmedia_vid_codec_mgr_alloc_codec(stream->codec_mgr, 1068 1064 &info->codec_info, … … 1073 1069 1074 1070 /* Get codec param: */ 1075 if (info->codec_param) 1076 stream->codec_param = *info->codec_param; 1077 else { 1071 if (info->codec_param) { 1072 stream->info.codec_param = pjmedia_vid_codec_param_clone( 1073 pool, 1074 info->codec_param); 1075 } else { 1076 pjmedia_vid_codec_param def_param; 1077 1078 1078 status = pjmedia_vid_codec_mgr_get_default_param(stream->codec_mgr, 1079 1079 &info->codec_info, 1080 & stream->codec_param);1080 &def_param); 1081 1081 if (status != PJ_SUCCESS) 1082 1082 return status; 1083 stream->info.codec_param = pjmedia_vid_codec_param_clone( 1084 pool, 1085 &def_param); 1086 pj_assert(stream->info.codec_param); 1083 1087 } 1084 1088 1085 1089 vfd_enc = pjmedia_format_get_video_format_detail( 1086 &stream->codec_param.enc_fmt, 1); 1090 &stream->info.codec_param->enc_fmt, 1091 PJ_TRUE); 1087 1092 1088 1093 /* Init stream: */ … … 1117 1122 1118 1123 /* Init codec param */ 1119 stream->codec_param.dir = info->dir; 1120 stream->codec_param.enc_mtu = PJMEDIA_MAX_MTU - sizeof(pjmedia_rtp_hdr); 1124 stream->info.codec_param->dir = info->dir; 1125 stream->info.codec_param->enc_mtu = PJMEDIA_MAX_MTU - 1126 sizeof(pjmedia_rtp_hdr); 1121 1127 1122 1128 /* Init and open the codec. */ … … 1124 1130 if (status != PJ_SUCCESS) 1125 1131 return status; 1126 status = stream->codec->op->open(stream->codec, &stream->codec_param);1132 status = stream->codec->op->open(stream->codec, stream->info.codec_param); 1127 1133 if (status != PJ_SUCCESS) 1128 1134 return status; … … 1140 1146 /* Validate the frame size */ 1141 1147 if (stream->frame_size == 0 || 1142 stream->frame_size > PJMEDIA_MAX_VIDEO_ FRAME_SIZE)1148 stream->frame_size > PJMEDIA_MAX_VIDEO_ENC_FRAME_SIZE) 1143 1149 { 1144 stream->frame_size = PJMEDIA_MAX_VIDEO_ FRAME_SIZE;1150 stream->frame_size = PJMEDIA_MAX_VIDEO_ENC_FRAME_SIZE; 1145 1151 } 1146 1152 … … 1151 1157 /* Create decoder channel */ 1152 1158 status = create_channel( pool, stream, PJMEDIA_DIR_DECODING, 1153 info-> codec_info.pt, info, &stream->dec);1159 info->rx_pt, info, &stream->dec); 1154 1160 if (status != PJ_SUCCESS) 1155 1161 return status; … … 1408 1414 1409 1415 /* 1416 * Get stream statistics. 1417 */ 1418 PJ_DEF(pj_status_t) pjmedia_vid_stream_get_stat( 1419 const pjmedia_vid_stream *stream, 1420 pjmedia_rtcp_stat *stat) 1421 { 1422 PJ_ASSERT_RETURN(stream && stat, PJ_EINVAL); 1423 1424 pj_memcpy(stat, &stream->rtcp.stat, sizeof(pjmedia_rtcp_stat)); 1425 return PJ_SUCCESS; 1426 } 1427 1428 1429 /* 1430 * Reset the stream statistics in the middle of a stream session. 1431 */ 1432 PJ_DEF(pj_status_t) pjmedia_vid_stream_reset_stat(pjmedia_vid_stream *stream) 1433 { 1434 PJ_ASSERT_RETURN(stream, PJ_EINVAL); 1435 1436 pjmedia_rtcp_init_stat(&stream->rtcp.stat); 1437 1438 return PJ_SUCCESS; 1439 } 1440 1441 1442 #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) 1443 /* 1444 * Get stream extended statistics. 1445 */ 1446 PJ_DEF(pj_status_t) pjmedia_stream_get_stat_xr( 1447 const pjmedia_vid_stream *stream, 1448 pjmedia_rtcp_xr_stat *stat) 1449 { 1450 PJ_ASSERT_RETURN(stream && stat, PJ_EINVAL); 1451 1452 if (stream->rtcp.xr_enabled) { 1453 pj_memcpy(stat, &stream->rtcp.xr_session.stat, 1454 sizeof(pjmedia_rtcp_xr_stat)); 1455 return PJ_SUCCESS; 1456 } 1457 return PJ_ENOTFOUND; 1458 } 1459 #endif 1460 1461 /* 1462 * Get jitter buffer state. 1463 */ 1464 PJ_DEF(pj_status_t) pjmedia_vid_stream_get_stat_jbuf( 1465 const pjmedia_vid_stream *stream, 1466 pjmedia_jb_state *state) 1467 { 1468 PJ_ASSERT_RETURN(stream && state, PJ_EINVAL); 1469 return pjmedia_jbuf_get_state(stream->jb, state); 1470 } 1471 1472 1473 /* 1474 * Get the stream info. 1475 */ 1476 PJ_DEF(pj_status_t) pjmedia_vid_stream_get_info( 1477 const pjmedia_vid_stream *stream, 1478 pjmedia_vid_stream_info *info) 1479 { 1480 PJ_ASSERT_RETURN(stream && info, PJ_EINVAL); 1481 pj_memcpy(info, &stream->info, sizeof(*info)); 1482 return PJ_SUCCESS; 1483 } 1484 1485 1486 /* 1410 1487 * Start stream. 1411 1488 */ … … 1434 1511 } 1435 1512 1436 1437 /*1438 * Get stream statistics.1439 */1440 PJ_DEF(pj_status_t) pjmedia_vid_stream_get_stat(1441 const pjmedia_vid_stream *stream,1442 pjmedia_rtcp_stat *stat)1443 {1444 PJ_ASSERT_RETURN(stream && stat, PJ_EINVAL);1445 1446 pj_memcpy(stat, &stream->rtcp.stat, sizeof(pjmedia_rtcp_stat));1447 return PJ_SUCCESS;1448 }1449 1450 1451 /*1452 * Reset the stream statistics in the middle of a stream session.1453 */1454 PJ_DEF(pj_status_t) pjmedia_vid_stream_reset_stat(pjmedia_vid_stream *stream)1455 {1456 PJ_ASSERT_RETURN(stream, PJ_EINVAL);1457 1458 pjmedia_rtcp_init_stat(&stream->rtcp.stat);1459 1460 return PJ_SUCCESS;1461 }1462 1463 1464 #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)1465 /*1466 * Get stream extended statistics.1467 */1468 PJ_DEF(pj_status_t) pjmedia_stream_get_stat_xr(1469 const pjmedia_vid_stream *stream,1470 pjmedia_rtcp_xr_stat *stat)1471 {1472 PJ_ASSERT_RETURN(stream && stat, PJ_EINVAL);1473 1474 if (stream->rtcp.xr_enabled) {1475 pj_memcpy(stat, &stream->rtcp.xr_session.stat,1476 sizeof(pjmedia_rtcp_xr_stat));1477 return PJ_SUCCESS;1478 }1479 return PJ_ENOTFOUND;1480 }1481 #endif1482 1483 /*1484 * Get jitter buffer state.1485 */1486 PJ_DEF(pj_status_t) pjmedia_vid_stream_get_stat_jbuf(1487 const pjmedia_vid_stream *stream,1488 pjmedia_jb_state *state)1489 {1490 PJ_ASSERT_RETURN(stream && state, PJ_EINVAL);1491 return pjmedia_jbuf_get_state(stream->jb, state);1492 }1493 1513 1494 1514 /* … … 1579 1599 */ 1580 1600 pt = pj_strtoul(&local_m->desc.fmt[0]); 1601 si->rx_pt = pt; 1581 1602 if (pt < 96) { 1582 1603 const pjmedia_vid_codec_info *p_info; … … 1660 1681 1661 1682 /* Get local fmtp for our decoder. */ 1662 pjmedia_stream_info_parse_fmtp(pool, local_m, pt,1683 pjmedia_stream_info_parse_fmtp(pool, local_m, si->rx_pt, 1663 1684 &si->codec_param->dec_fmtp); 1664 1685 … … 1718 1739 1719 1740 /* Media type must be audio */ 1720 if (pj_stricmp(&local_m->desc.media, &ID_VIDEO) == 0)1741 if (pj_stricmp(&local_m->desc.media, &ID_VIDEO) != 0) 1721 1742 return PJMEDIA_EINVALIMEDIATYPE; 1722 1743
Note: See TracChangeset
for help on using the changeset viewer.