Mercurial > mplayer.hg
comparison stream/tvi_dshow.c @ 25057:7d74c1a2c840
Move chains building code into separate routines.
This makes code more readable and will allow
building particular chain before start().
author | voroshil |
---|---|
date | Sun, 18 Nov 2007 05:02:49 +0000 |
parents | 8abe2ef6bee9 |
children | ac9507b338ac |
comparison
equal
deleted
inserted
replaced
25056:4abb9224e69b | 25057:7d74c1a2c840 |
---|---|
2400 audio_bitrate,video_buf_size,video_bitrate,audio_buf_size); | 2400 audio_bitrate,video_buf_size,video_bitrate,audio_buf_size); |
2401 return audio_buf_size; | 2401 return audio_buf_size; |
2402 } | 2402 } |
2403 | 2403 |
2404 /** | 2404 /** |
2405 * \brief playback/capture real start | 2405 * \brief build video stream chain in graph |
2406 * | 2406 * \param priv private data structure |
2407 * \param priv driver's private data structure | 2407 * |
2408 * | 2408 * \return S_OK if chain was built successfully, apropriate error code otherwise |
2409 * \return 1 if success, 0 - otherwise | 2409 */ |
2410 * | 2410 static HRESULT build_video_chain(priv_t *priv) |
2411 * TODO: move some code from init() here | |
2412 */ | |
2413 static int start(priv_t * priv) | |
2414 { | 2411 { |
2415 HRESULT hr; | 2412 HRESULT hr; |
2416 | 2413 |
2417 if (priv->pVideoStreamConfig) { | 2414 if (priv->pVideoStreamConfig) { |
2418 hr = OLE_CALL_ARGS(priv->pVideoStreamConfig, SetFormat, priv->pmtVideo); | 2415 hr = OLE_CALL_ARGS(priv->pVideoStreamConfig, SetFormat, priv->pmtVideo); |
2419 if (FAILED(hr)) { | 2416 if (FAILED(hr)) { |
2420 mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableSelectVideoFormat, (unsigned int)hr); | 2417 mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableSelectVideoFormat, (unsigned int)hr); |
2421 } | 2418 } |
2422 } | 2419 } |
2423 | 2420 |
2424 if (!priv->immediate_mode && priv->pAudioStreamConfig) { | 2421 priv->v_buf=calloc(1,sizeof(grabber_ringbuffer_t)); |
2422 | |
2423 if (priv->tv_param->buffer_size >= 0) { | |
2424 priv->v_buf->buffersize = priv->tv_param->buffer_size; | |
2425 } else { | |
2426 priv->v_buf->buffersize = 16; | |
2427 } | |
2428 | |
2429 priv->v_buf->buffersize *= 1024 * 1024; | |
2430 hr=build_sub_graph(priv, priv->pVideoFilter, priv->v_buf, priv->pmtVideo,&PIN_CATEGORY_CAPTURE); | |
2431 if(FAILED(hr)){ | |
2432 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableBuildVideoSubGraph,(unsigned int)hr); | |
2433 return hr; | |
2434 } | |
2435 return S_OK; | |
2436 } | |
2437 | |
2438 /** | |
2439 * \brief build audio stream chain in graph | |
2440 * \param priv private data structure | |
2441 * | |
2442 * \return S_OK if chain was built successfully, apropriate error code otherwise | |
2443 */ | |
2444 static HRESULT build_audio_chain(priv_t *priv) | |
2445 { | |
2446 HRESULT hr; | |
2447 | |
2448 if(priv->immediate_mode) | |
2449 return S_OK; | |
2450 | |
2451 if (priv->pAudioStreamConfig) { | |
2425 hr = OLE_CALL_ARGS(priv->pAudioStreamConfig, SetFormat, | 2452 hr = OLE_CALL_ARGS(priv->pAudioStreamConfig, SetFormat, |
2426 priv->pmtAudio); | 2453 priv->pmtAudio); |
2427 if (FAILED(hr)) { | 2454 if (FAILED(hr)) { |
2428 mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableSelectAudioFormat, (unsigned int)hr); | 2455 mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableSelectAudioFormat, (unsigned int)hr); |
2429 } | 2456 } |
2430 } | 2457 } |
2431 | 2458 |
2432 priv->v_buf=calloc(1,sizeof(grabber_ringbuffer_t)); | 2459 if(priv->pmtAudio){ |
2433 | |
2434 if (priv->tv_param->buffer_size >= 0) { | |
2435 priv->v_buf->buffersize = priv->tv_param->buffer_size; | |
2436 } else { | |
2437 priv->v_buf->buffersize = 16; | |
2438 } | |
2439 | |
2440 priv->v_buf->buffersize *= 1024 * 1024; | |
2441 hr=build_sub_graph(priv, priv->pVideoFilter, priv->v_buf, priv->pmtVideo,&PIN_CATEGORY_CAPTURE); | |
2442 if(FAILED(hr)){ | |
2443 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableBuildVideoSubGraph,(unsigned int)hr); | |
2444 return 0; | |
2445 } | |
2446 if(priv->pmtAudio && !priv->immediate_mode){ | |
2447 priv->a_buf=calloc(1,sizeof(grabber_ringbuffer_t)); | 2460 priv->a_buf=calloc(1,sizeof(grabber_ringbuffer_t)); |
2448 | 2461 |
2449 /* let the audio buffer be the same size (in seconds) than video one */ | 2462 /* let the audio buffer be the same size (in seconds) than video one */ |
2450 priv->a_buf->buffersize=audio_buf_size_from_video( | 2463 priv->a_buf->buffersize=audio_buf_size_from_video( |
2451 priv->v_buf->buffersize, | 2464 priv->v_buf->buffersize, |
2456 if(FAILED(hr)){ | 2469 if(FAILED(hr)){ |
2457 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableBuildAudioSubGraph,(unsigned int)hr); | 2470 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableBuildAudioSubGraph,(unsigned int)hr); |
2458 return 0; | 2471 return 0; |
2459 } | 2472 } |
2460 } | 2473 } |
2461 | 2474 return S_OK; |
2475 } | |
2476 | |
2477 /** | |
2478 * \brief build VBI stream chain in graph | |
2479 * \param priv private data structure | |
2480 * | |
2481 * \return S_OK if chain was built successfully, apropriate error code otherwise | |
2482 */ | |
2483 static HRESULT build_vbi_chain(priv_t *priv) | |
2484 { | |
2462 #ifdef HAVE_TV_TELETEXT | 2485 #ifdef HAVE_TV_TELETEXT |
2486 HRESULT hr; | |
2487 | |
2463 if(priv->tv_param->tdevice) | 2488 if(priv->tv_param->tdevice) |
2464 { | 2489 { |
2465 priv->vbi_buf=calloc(1,sizeof(grabber_ringbuffer_t)); | 2490 priv->vbi_buf=calloc(1,sizeof(grabber_ringbuffer_t)); |
2466 init_ringbuffer(priv->vbi_buf,24,priv->tsp.bufsize); | 2491 init_ringbuffer(priv->vbi_buf,24,priv->tsp.bufsize); |
2467 | 2492 |
2472 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableBuildVBISubGraph,(unsigned int)hr); | 2497 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableBuildVBISubGraph,(unsigned int)hr); |
2473 return 0; | 2498 return 0; |
2474 } | 2499 } |
2475 } | 2500 } |
2476 #endif | 2501 #endif |
2502 return S_OK; | |
2503 } | |
2504 | |
2505 /** | |
2506 * \brief playback/capture real start | |
2507 * | |
2508 * \param priv driver's private data structure | |
2509 * | |
2510 * \return 1 if success, 0 - otherwise | |
2511 * | |
2512 * TODO: move some code from init() here | |
2513 */ | |
2514 static int start(priv_t * priv) | |
2515 { | |
2516 HRESULT hr; | |
2517 | |
2518 hr = build_video_chain(priv); | |
2519 if(FAILED(hr)) | |
2520 return 0; | |
2521 | |
2522 hr = build_audio_chain(priv); | |
2523 if(FAILED(hr)) | |
2524 return 0; | |
2525 | |
2526 hr = build_vbi_chain(priv); | |
2527 if(FAILED(hr)) | |
2528 return 0; | |
2529 | |
2477 /* | 2530 /* |
2478 Graph is ready to capture. Starting graph. | 2531 Graph is ready to capture. Starting graph. |
2479 */ | 2532 */ |
2480 if (mp_msg_test(MSGT_TV, MSGL_DBG2)) { | 2533 if (mp_msg_test(MSGT_TV, MSGL_DBG2)) { |
2481 mp_msg(MSGT_TV, MSGL_DBG2, "Debug pause 10sec\n"); | 2534 mp_msg(MSGT_TV, MSGL_DBG2, "Debug pause 10sec\n"); |