?? ts.c
字號:
var_Get( p_mux, SOUT_CFG_PREFIX "dts-delay", &val ); p_sys->i_dts_delay = (int64_t)val.i_int * 1000; msg_Dbg( p_mux, "shaping="I64Fd" pcr="I64Fd" dts_delay="I64Fd, p_sys->i_shaping_delay, p_sys->i_pcr_delay, p_sys->i_dts_delay ); var_Get( p_mux, SOUT_CFG_PREFIX "use-key-frames", &val ); p_sys->b_use_key_frames = val.b_bool; /* for TS generation */ p_sys->i_pcr = 0; p_sys->csa = NULL; var_Get( p_mux, SOUT_CFG_PREFIX "csa-ck", &val ); if( val.psz_string && *val.psz_string ) { char *psz = val.psz_string; /* skip 0x */ if( psz[0] == '0' && ( psz[1] == 'x' || psz[1] == 'X' ) ) { psz += 2; } if( strlen( psz ) != 16 ) { msg_Dbg( p_mux, "invalid csa ck (it must be 16 chars long)" ); } else { uint64_t i_ck = strtoull( psz, NULL, 16 ); uint8_t ck[8]; int i; for( i = 0; i < 8; i++ ) { ck[i] = ( i_ck >> ( 56 - 8*i) )&0xff; }#ifndef TS_NO_CSA_CK_MSG msg_Dbg( p_mux, "using CSA scrambling with ck=%x:%x:%x:%x:%x:%x:%x:%x", ck[0], ck[1], ck[2], ck[3], ck[4], ck[5], ck[6], ck[7] );#endif p_sys->csa = csa_New(); if( p_sys->csa ) { vlc_value_t pkt_val; csa_SetCW( p_sys->csa, ck, ck ); var_Get( p_mux, SOUT_CFG_PREFIX "csa-pkt", &pkt_val ); if( pkt_val.i_int < 12 || pkt_val.i_int > 188 ) { msg_Err( p_mux, "wrong packet size %d specified.", pkt_val.i_int ); msg_Warn( p_mux, "using default packet size of 188 bytes" ); p_sys->i_csa_pkt_size = 188; } else p_sys->i_csa_pkt_size = pkt_val.i_int; msg_Dbg( p_mux, "encrypting %d bytes of packet", p_sys->i_csa_pkt_size ); } } } if( val.psz_string ) free( val.psz_string ); var_Get( p_mux, SOUT_CFG_PREFIX "crypt-audio", &val ); p_sys->b_crypt_audio = val.b_bool; var_Get( p_mux, SOUT_CFG_PREFIX "crypt-video", &val ); p_sys->b_crypt_video = val.b_bool; return VLC_SUCCESS;}/***************************************************************************** * Close: *****************************************************************************/static void Close( vlc_object_t * p_this ){ sout_mux_t *p_mux = (sout_mux_t*)p_this; sout_mux_sys_t *p_sys = p_mux->p_sys; int i; if( p_sys->csa ) { csa_Delete( p_sys->csa ); } for( i = 0; i < MAX_PMT; i++ ) { if( p_sys->sdt_descriptors[i].psz_service_name != NULL ) free( p_sys->sdt_descriptors[i].psz_service_name ); if( p_sys->sdt_descriptors[i].psz_provider != NULL ) free( p_sys->sdt_descriptors[i].psz_provider ); } if( p_sys->dvbpmt != NULL ) /* safety */ free ( p_sys->dvbpmt ); free( p_sys );}/***************************************************************************** * Control: *****************************************************************************/static int Control( sout_mux_t *p_mux, int i_query, va_list args ){ vlc_bool_t *pb_bool; char **ppsz; switch( i_query ) { case MUX_CAN_ADD_STREAM_WHILE_MUXING: pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * ); *pb_bool = VLC_TRUE; return VLC_SUCCESS; case MUX_GET_ADD_STREAM_WAIT: pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * ); *pb_bool = VLC_FALSE; return VLC_SUCCESS; case MUX_GET_MIME: ppsz = (char**)va_arg( args, char ** ); *ppsz = strdup( "video/mpeg" ); /* FIXME not sure */ return VLC_SUCCESS; default: return VLC_EGENERIC; }}/***************************************************************************** * AddStream: called for each stream addition *****************************************************************************/static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ){ sout_mux_sys_t *p_sys = p_mux->p_sys; ts_stream_t *p_stream; int i; p_input->p_sys = p_stream = malloc( sizeof( ts_stream_t ) ); /* Init this new stream */ if ( p_sys->b_es_id_pid ) p_stream->i_pid = p_input->p_fmt->i_id & 0x1fff; else p_stream->i_pid = AllocatePID( p_sys, p_input->p_fmt->i_cat ); p_stream->i_codec = p_input->p_fmt->i_codec; p_stream->i_continuity_counter = 0; p_stream->b_discontinuity = VLC_FALSE; p_stream->i_decoder_specific_info = 0; p_stream->p_decoder_specific_info = NULL; msg_Dbg( p_mux, "adding input codec=%4.4s pid=%d", (char*)&p_input->p_fmt->i_codec, p_stream->i_pid ); /* All others fields depand on codec */ switch( p_input->p_fmt->i_cat ) { case VIDEO_ES: switch( p_input->p_fmt->i_codec ) { case VLC_FOURCC( 'm', 'p','g', 'v' ): /* TODO: do we need to check MPEG-I/II ? */ p_stream->i_stream_type = 0x02; p_stream->i_stream_id = 0xe0; break; case VLC_FOURCC( 'm', 'p','4', 'v' ): p_stream->i_stream_type = 0x10; p_stream->i_stream_id = 0xe0; p_stream->i_es_id = p_stream->i_pid; break; case VLC_FOURCC( 'h', '2','6', '4' ): p_stream->i_stream_type = 0x1b; p_stream->i_stream_id = 0xe0; break; /* XXX dirty dirty but somebody want that: * using crapy MS-codec XXX */ /* I didn't want to do that :P */ case VLC_FOURCC( 'H', '2', '6', '3' ): case VLC_FOURCC( 'I', '2', '6', '3' ): case VLC_FOURCC( 'W', 'M', 'V', '3' ): case VLC_FOURCC( 'W', 'M', 'V', '2' ): case VLC_FOURCC( 'W', 'M', 'V', '1' ): case VLC_FOURCC( 'D', 'I', 'V', '3' ): case VLC_FOURCC( 'D', 'I', 'V', '2' ): case VLC_FOURCC( 'D', 'I', 'V', '1' ): case VLC_FOURCC( 'M', 'J', 'P', 'G' ): p_stream->i_stream_type = 0xa0; /* private */ p_stream->i_stream_id = 0xa0; /* beurk */ p_stream->i_bih_codec = p_input->p_fmt->i_codec; p_stream->i_bih_width = p_input->p_fmt->video.i_width; p_stream->i_bih_height = p_input->p_fmt->video.i_height; break; default: free( p_stream ); return VLC_EGENERIC; } p_sys->i_video_bound++; break; case AUDIO_ES: switch( p_input->p_fmt->i_codec ) { case VLC_FOURCC( 'm', 'p','g', 'a' ): p_stream->i_stream_type = p_input->p_fmt->audio.i_rate >= 32000 ? 0x03 : 0x04; p_stream->i_stream_id = 0xc0; break; case VLC_FOURCC( 'a', '5','2', ' ' ): p_stream->i_stream_type = 0x81; p_stream->i_stream_id = 0xbd; break; case VLC_FOURCC( 'l', 'p','c', 'm' ): p_stream->i_stream_type = 0x83; p_stream->i_stream_id = 0xbd; break; case VLC_FOURCC( 'd', 't','s', ' ' ): p_stream->i_stream_type = 0x06; p_stream->i_stream_id = 0xbd; break; case VLC_FOURCC( 'm', 'p','4', 'a' ): p_stream->i_stream_type = 0x11; p_stream->i_stream_id = 0xfa; p_sys->i_mpeg4_streams++; p_stream->i_es_id = p_stream->i_pid; break; default: free( p_stream ); return VLC_EGENERIC; } p_sys->i_audio_bound++; break; case SPU_ES: switch( p_input->p_fmt->i_codec ) { case VLC_FOURCC( 's', 'p','u', ' ' ): p_stream->i_stream_type = 0x82; p_stream->i_stream_id = 0xbd; break; case VLC_FOURCC( 's', 'u','b', 't' ): p_stream->i_stream_type = 0x12; p_stream->i_stream_id = 0xfa; p_sys->i_mpeg4_streams++; p_stream->i_es_id = p_stream->i_pid; break; case VLC_FOURCC('d','v','b','s'): p_stream->i_stream_type = 0x06; p_stream->i_es_id = p_input->p_fmt->subs.dvb.i_id; p_stream->i_stream_id = 0xbd; break; case VLC_FOURCC('t','e','l','x'): p_stream->i_stream_type = 0x06; p_stream->i_stream_id = 0xbd; /* FIXME */ break; default: free( p_stream ); return VLC_EGENERIC; } break; default: free( p_stream ); return VLC_EGENERIC; } p_stream->i_langs = 1+p_input->p_fmt->i_extra_languages; p_stream->lang = malloc(p_stream->i_langs*3); i = 1; p_stream->lang[0] = p_stream->lang[1] = p_stream->lang[2] = '\0'; if( p_input->p_fmt->psz_language ) { char *psz = p_input->p_fmt->psz_language; const iso639_lang_t *pl = NULL; if( strlen( psz ) == 2 ) { pl = GetLang_1( psz ); } else if( strlen( psz ) == 3 ) { pl = GetLang_2B( psz ); if( !strcmp( pl->psz_iso639_1, "??" ) ) { pl = GetLang_2T( psz ); } } if( pl && strcmp( pl->psz_iso639_1, "??" ) ) { p_stream->lang[0] = pl->psz_iso639_2T[0]; p_stream->lang[1] = pl->psz_iso639_2T[1]; p_stream->lang[2] = pl->psz_iso639_2T[2]; msg_Dbg( p_mux, " - lang=%c%c%c", p_stream->lang[0], p_stream->lang[1], p_stream->lang[2] ); } } while( i < p_stream->i_langs ) { if( p_input->p_fmt->p_extra_languages[i-1].psz_language ) { char *psz = p_input->p_fmt->p_extra_languages[i-1].psz_language; const iso639_lang_t *pl = NULL; if( strlen( psz ) == 2 ) { pl = GetLang_1( psz ); } else if( strlen( psz ) == 3 ) { pl = GetLang_2B( psz ); if( !strcmp( pl->psz_iso639_1, "??" ) ) { pl = GetLang_2T( psz ); } } if( pl && strcmp( pl->psz_iso639_1, "??" ) ) { p_stream->lang[i*3+0] = pl->psz_iso639_2T[0]; p_stream->lang[i*3+1] = pl->psz_iso639_2T[1]; p_stream->lang[i*3+2] = pl->psz_iso639_2T[2]; msg_Dbg( p_mux, " - lang=%c%c%c", p_stream->lang[i*3+0], p_stream->lang[i*3+1], p_stream->lang[i*3+2] ); } } i++; } /* Copy extra data (VOL for MPEG-4 and extra BitMapInfoHeader for VFW */ p_stream->i_decoder_specific_info = p_input->p_fmt->i_extra; if( p_stream->i_decoder_specific_info > 0 ) { p_stream->p_decoder_specific_info = malloc( p_stream->i_decoder_specific_info ); memcpy( p_stream->p_decoder_specific_info, p_input->p_fmt->p_extra, p_input->p_fmt->i_extra ); } /* Create decoder specific info for subt */ if( p_stream->i_codec == VLC_FOURCC( 's', 'u','b', 't' ) ) { uint8_t *p; p_stream->i_decoder_specific_info = 55; p_stream->p_decoder_specific_info = p = malloc( p_stream->i_decoder_specific_info ); p[0] = 0x10; /* textFormat, 0x10 for 3GPP TS 26.245 */ p[1] = 0x00; /* flags: 1b: associated video info flag 3b: reserved 1b: duration flag 3b: reserved */ p[2] = 52; /* remaining size */ p += 3; p[0] = p[1] = p[2] = p[3] = 0; p+=4; /* display flags */ *p++ = 0; /* horizontal justification (-1: left, 0 center, 1 right) */ *p++ = 1; /* vertical justification (-1: top, 0 center, 1 bottom) */ p[0] = p[1] = p[2] = 0x00; p+=3;/* background rgb */ *p++ = 0xff; /* background a */ p[0] = p[1] = 0; p += 2; /* text box top */ p[0] = p[1] = 0; p += 2; /* text box left */ p[0] = p[1] = 0; p += 2; /* text box bottom */ p[0] = p[1] = 0; p += 2; /* text box right */ p[0] = p[1] = 0; p += 2; /* start char */ p[0] = p[1] = 0; p += 2; /* end char */ p[0] = p[1] = 0; p += 2; /* default font id */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -