提交 e6fbe572 authored 作者: Anthony Minessale's avatar Anthony Minessale 提交者: Michael Jerris

FS-7499 FS-7500 mods for interop against latest chrome builds

上级 9ccf71f4
......@@ -159,7 +159,7 @@ typedef union {
#endif
#define __IS_VP8_KEY_FRAME(byte) (((byte) & 0x01) ^ 0x01)
#define __IS_VP8_KEY_FRAME(byte) !(((byte) & 0x01))
static inline int IS_VP8_KEY_FRAME(uint8_t *data)
{
uint8_t S;
......@@ -227,6 +227,7 @@ struct vpx_context {
uint8_t decoder_init;
switch_buffer_t *vpx_packet_buffer;
int got_key_frame;
int got_start_frame;
uint32_t last_received_timestamp;
switch_bool_t last_received_complete_picture;
int need_key_frame;
......@@ -272,6 +273,7 @@ static switch_status_t init_decoder(switch_codec_t *codec)
context->last_received_complete_picture = 0;
context->decoder_init = 1;
context->got_key_frame = 0;
context->got_start_frame = 0;
// the types of post processing to be done, should be combination of "vp8_postproc_level"
ppcfg.post_proc_flag = VP8_DEBLOCK;//VP8_DEMACROBLOCK | VP8_DEBLOCK;
// the strength of deblocking, valid range [0, 16]
......@@ -681,29 +683,57 @@ static switch_status_t buffer_vp8_packets(vpx_context_t *context, switch_frame_t
uint8_t *data = frame->data;
uint8_t S;
uint8_t DES;
//uint8_t PID;
uint8_t PID;
int len;
int key = 0;
#if 0
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
"VIDEO VPX: seq: %d ts: %u len: %ld %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x mark: %d\n",
frame->seq, frame->timestamp, frame->datalen,
*((uint8_t *)data), *((uint8_t *)data + 1),
*((uint8_t *)data + 2), *((uint8_t *)data + 3),
*((uint8_t *)data + 4), *((uint8_t *)data + 5),
*((uint8_t *)data + 6), *((uint8_t *)data + 7),
*((uint8_t *)data + 8), *((uint8_t *)data + 9),
*((uint8_t *)data + 10), frame->m);
#endif
DES = *data;
data++;
S = DES & 0x10;
//PID = DES & 0x07;
S = (DES & 0x10);
PID = DES & 0x07;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DATA LEN %d S BIT %d PID: %d\n", frame->datalen, S, PID);
if (DES & 0x80) { // X
uint8_t X = *data;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "X BIT SET\n");
data++;
if (X & 0x80) { // I
uint8_t M = (*data) & 0x80;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "I BIT SET\n");
data++;
if (M) data++;
if (M) {
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "M BIT SET\n");
data++;
}
}
if (X & 0x40) {
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "L BIT SET\n");
data++; // L
}
if (X & 0x30) {
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "T/K BIT SET\n");
data++; // T/K
}
if (X & 0x40) data++; // L
if (X & 0x30) data++; // T/K
}
if (!switch_buffer_inuse(context->vpx_packet_buffer) && !S) {
if (context->got_key_frame > 0) {
context->got_key_frame = 0;
context->got_start_frame = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG2, "packet loss?\n");
}
return SWITCH_STATUS_MORE_DATA;
......@@ -712,10 +742,14 @@ static switch_status_t buffer_vp8_packets(vpx_context_t *context, switch_frame_t
if (S) {
switch_buffer_zero(context->vpx_packet_buffer);
context->last_received_timestamp = frame->timestamp;
if (PID == 0) {
key = __IS_VP8_KEY_FRAME(*data);
}
}
len = frame->datalen - (data - (uint8_t *)frame->data);
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POST PARSE: DATA LEN %d KEY %d KEYBYTE = %0x\n", len, key, *data);
if (len <= 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid packet %d\n", len);
return SWITCH_STATUS_RESTART;
......@@ -802,7 +836,11 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
// context->last_received_timestamp = frame->timestamp;
context->last_received_complete_picture = frame->m ? SWITCH_TRUE : SWITCH_FALSE;
if (is_keyframe || is_start) {
if (is_start) {
context->got_start_frame = 1;
}
if (is_keyframe) {
if (context->got_key_frame <= 0) {
context->got_key_frame = 1;
if (!is_keyframe) {
......@@ -815,7 +853,9 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
if ((--context->got_key_frame % 200) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Waiting for key frame %d\n", context->got_key_frame);
}
switch_goto_status(SWITCH_STATUS_MORE_DATA, end);
if (!context->got_start_frame) {
switch_goto_status(SWITCH_STATUS_MORE_DATA, end);
}
}
......@@ -839,12 +879,12 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
uint8_t *data;
int corrupted = 0;
int err;
//int keyframe = 0;
int keyframe = 0;
//printf("WTF %d %ld\n", frame->m, len);
switch_buffer_peek_zerocopy(context->vpx_packet_buffer, (void *)&data);
//keyframe = (*data & 0x01) ? 0 : 1;
keyframe = (*data & 0x01) ? 0 : 1;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffered: %" SWITCH_SIZE_T_FMT ", key: %d\n", len, keyframe);
......@@ -871,17 +911,22 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
switch_buffer_zero(context->vpx_packet_buffer);
if (!frame->img) {
context->need_decoder_reset = 1;
//context->need_decoder_reset = 1;
context->got_key_frame = 0;
context->got_start_frame = 0;
status = SWITCH_STATUS_RESTART;
}
}
end:
//if (status == SWITCH_STATUS_RESTART) {
// context->need_decoder_reset = 1;
//}
if (status == SWITCH_STATUS_RESTART) {
switch_buffer_zero(context->vpx_packet_buffer);
//context->need_decoder_reset = 1;
context->got_key_frame = 0;
context->got_start_frame = 0;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "RESET VPX\n");
}
if (!frame->img || status == SWITCH_STATUS_RESTART) {
status = SWITCH_STATUS_MORE_DATA;
......
......@@ -1852,7 +1852,13 @@ SWITCH_DECLARE(void) switch_channel_set_flag_value(switch_channel_t *channel, sw
switch_channel_set_variable(channel, "recovered", "true");
}
if (flag == CF_VIDEO_ECHO) {
switch_core_session_start_video_thread(channel->session);
}
if (flag == CF_VIDEO_DECODED_READ) {
switch_core_session_request_video_refresh(channel->session);
switch_core_session_start_video_thread(channel->session);
if (!switch_core_session_in_video_thread(channel->session)) {
switch_channel_wait_for_flag(channel, CF_VIDEO_READY, SWITCH_TRUE, 10000, NULL);
}
......
......@@ -3154,7 +3154,7 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_
engine->ice_in.cand_idx++;
for (i = 0; i < engine->cand_acl_count; i++) {
if (!engine->ice_in.chosen[cid] && switch_check_network_list_ip(fields[4], engine->cand_acl[i])) {
if (!engine->ice_in.chosen[cid] && !strchr(fields[4], ':') && switch_check_network_list_ip(fields[4], engine->cand_acl[i])) {
engine->ice_in.chosen[cid] = engine->ice_in.cand_idx;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_NOTICE,
"Choose %s Candidate cid: %d proto: %s type: %s addr: %s:%s\n",
......@@ -4778,6 +4778,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_file(switch_core_ses
switch_mutex_unlock(v_engine->mh.file_mutex);
switch_core_session_start_video_thread(session);
return SWITCH_STATUS_SUCCESS;
}
......@@ -4931,7 +4933,7 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi
} else if (switch_channel_test_flag(channel, CF_VIDEO_DECODED_READ)) {
send_blank = 1;
}
if ((send_blank || switch_channel_test_flag(channel, CF_VIDEO_BLANK)) &&
!session->video_read_callback && !switch_channel_test_flag(session->channel, CF_BRIDGED)) {
fr.img = blank_img;
......@@ -5003,7 +5005,6 @@ SWITCH_DECLARE(void) switch_core_media_start_video_function(switch_core_session_
smh->video_function = video_function;
smh->video_user_data = user_data;
switch_core_session_video_reset(session);
switch_core_session_start_video_thread(session);
}
switch_mutex_unlock(smh->control_mutex);
}
......@@ -5191,7 +5192,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_proxy_remote_addr(switch_core_
!switch_channel_test_flag(session->channel, CF_AVPF)) {
/* Reactivate the NAT buster flag. */
switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
switch_core_session_start_video_thread(session);
}
if (switch_media_handle_test_media_flag(smh, SCMF_AUTOFIX_TIMING)) {
v_engine->check_frames = 0;
......@@ -6169,7 +6169,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
v_engine->local_sdp_ip, v_engine->local_sdp_port, v_engine->cur_payload_map->remote_sdp_ip,
v_engine->cur_payload_map->remote_sdp_port, v_engine->cur_payload_map->agreed_pt);
switch_core_session_start_video_thread(session);
switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->cur_payload_map->agreed_pt);
}
}
......@@ -6202,7 +6201,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
!((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
/* Reactivate the NAT buster flag. */
switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
switch_core_session_start_video_thread(session);
}
}
......@@ -6317,7 +6315,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
}
switch_rtp_set_payload_map(v_engine->rtp_session, &v_engine->payload_map);
switch_core_session_start_video_thread(session);
//switch_core_session_start_video_thread(session);
switch_channel_set_flag(session->channel, CF_VIDEO);
if ((ssrc = switch_channel_get_variable(session->channel, "rtp_use_video_ssrc"))) {
......@@ -6923,7 +6921,7 @@ static void add_fb(char *buf, uint32_t buflen, int pt, int fir, int nack, int pl
sp = " ";
}
if (fir) {
if (!zstr(zfir) || !zstr(ztmmbr)) {
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=rtcp-fb:%d ccm %s%s%s\n", pt, zfir, sp, ztmmbr);
}
......@@ -7324,7 +7322,8 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
if (!zstr(a_engine->local_dtls_fingerprint.type)) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fingerprint:%s %s\na=setup:%s\n", a_engine->local_dtls_fingerprint.type,
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fingerprint:%s %s\na=setup:%s\na=mid:audio\n",
a_engine->local_dtls_fingerprint.type,
a_engine->local_dtls_fingerprint.str, get_setup(session));
}
......@@ -7358,13 +7357,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
ice_out = &a_engine->ice_out;
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u cname:%s\n", a_engine->ssrc, smh->cname);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u msid:%s a0\n", a_engine->ssrc, smh->msid);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u mslabel:%s\n", a_engine->ssrc, smh->msid);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u label:%sa0\n", a_engine->ssrc, smh->msid);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-ufrag:%s\n", ice_out->ufrag);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-pwd:%s\n", ice_out->pwd);
......@@ -7406,7 +7399,13 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
);
}
}
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u cname:%s\n", a_engine->ssrc, smh->cname);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u msid:%s a0\n", a_engine->ssrc, smh->msid);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u mslabel:%s\n", a_engine->ssrc, smh->msid);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u label:%sa0\n", a_engine->ssrc, smh->msid);
#ifdef GOOGLE_ICE
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-options:google-ice\n");
......@@ -8600,13 +8599,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se
case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ:
{
if (v_engine->rtp_session) {
if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PLI)) {
switch_rtp_video_loss(v_engine->rtp_session);
}
if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_FIR)) {
switch_rtp_video_refresh(v_engine->rtp_session);
}
}// else {
if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PLI)) {
switch_rtp_video_loss(v_engine->rtp_session);
}
// }
}
}
......@@ -10482,7 +10481,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
if (status == SWITCH_STATUS_INUSE) {
*frame = &runtime.dummy_cng_frame;
switch_yield(20000);
switch_cond_next();
return SWITCH_STATUS_SUCCESS;
}
......@@ -10541,7 +10540,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
if (!(*frame)->img) {
*frame = &runtime.dummy_cng_frame;
switch_yield(66000);
switch_cond_next();
return SWITCH_STATUS_SUCCESS;
}
}
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论