root/modules/misc/stats/decoder.c
| Revision d794dd855b59cba17d4b3c39f5c864ba22c8a1c1, 3.7 kB (checked in by Rémi Denis-Courmont <rdenis@simphalempin.com>, 5 months ago) | |
|---|---|
| |
| Line | |
|---|---|
| 1 | /***************************************************************************** |
| 2 | * decoder.c: stats decoder plugin for vlc. |
| 3 | ***************************************************************************** |
| 4 | * Copyright (C) 2002-2008 the VideoLAN team |
| 5 | * |
| 6 | * Authors: Samuel Hocevar <sam@zoy.org> |
| 7 | * Pierre d'Herbemont <pdherbemont@videolan.org> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
| 22 | *****************************************************************************/ |
| 23 | |
| 24 | /***************************************************************************** |
| 25 | * Preamble |
| 26 | *****************************************************************************/ |
| 27 | #ifdef HAVE_CONFIG_H |
| 28 | # include "config.h" |
| 29 | #endif |
| 30 | |
| 31 | #include <vlc_common.h> |
| 32 | #include <vlc_codec.h> |
| 33 | #include <vlc_vout.h> |
| 34 | |
| 35 | #include "stats.h" |
| 36 | |
| 37 | /***************************************************************************** |
| 38 | * Local prototypes |
| 39 | *****************************************************************************/ |
| 40 | static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ); |
| 41 | |
| 42 | /***************************************************************************** |
| 43 | * OpenDecoder: Open the decoder |
| 44 | *****************************************************************************/ |
| 45 | int OpenDecoder ( vlc_object_t *p_this ) |
| 46 | { |
| 47 | decoder_t *p_dec = (decoder_t*)p_this; |
| 48 | |
| 49 | msg_Dbg( p_this, "opening stats decoder" ); |
| 50 | |
| 51 | /* Set callbacks */ |
| 52 | p_dec->pf_decode_video = DecodeBlock; |
| 53 | p_dec->pf_decode_audio = NULL; |
| 54 | p_dec->pf_decode_sub = NULL; |
| 55 | |
| 56 | return VLC_SUCCESS; |
| 57 | } |
| 58 | |
| 59 | /**************************************************************************** |
| 60 | * RunDecoder: the whole thing |
| 61 | ****************************************************************************/ |
| 62 | static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) |
| 63 | { |
| 64 | block_t *p_block; |
| 65 | picture_t * p_pic = NULL; |
| 66 | |
| 67 | if( !pp_block || !*pp_block ) return NULL; |
| 68 | p_block = *pp_block; |
| 69 | |
| 70 | p_dec->fmt_out.video.i_width = 100; |
| 71 | p_dec->fmt_out.video.i_height = 100; |
| 72 | p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR; |
| 73 | p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','2','0'); |
| 74 | |
| 75 | p_pic = p_dec->pf_vout_buffer_new( p_dec ); |
| 76 | |
| 77 | if( p_block->i_buffer == kBufferSize ) |
| 78 | { |
| 79 | msg_Dbg( p_dec, "got %"PRIu64" ms", |
| 80 | *(mtime_t *)p_block->p_buffer / 1000 ); |
| 81 | msg_Dbg( p_dec, "got %"PRIu64" ms offset", |
| 82 | (mdate() - *(mtime_t *)p_block->p_buffer) / 1000 ); |
| 83 | *(mtime_t *)(p_pic->p->p_pixels) = *(mtime_t *)p_block->p_buffer; |
| 84 | } |
| 85 | else |
| 86 | { |
| 87 | msg_Dbg( p_dec, "got a packet not from stats demuxer" ); |
| 88 | *(mtime_t *)(p_pic->p->p_pixels) = mdate(); |
| 89 | } |
| 90 | |
| 91 | p_pic->date = p_block->i_pts ? p_block->i_pts : p_block->i_dts; |
| 92 | p_pic->b_force = true; |
| 93 | |
| 94 | block_Release( p_block ); |
| 95 | *pp_block = NULL; |
| 96 | return p_pic; |
| 97 | } |
| 98 | |
| 99 | /***************************************************************************** |
| 100 | * CloseDecoder: decoder destruction |
| 101 | *****************************************************************************/ |
| 102 | void CloseDecoder ( vlc_object_t *p_this ) |
| 103 | { |
| 104 | msg_Dbg( p_this, "closing stats decoder" ); |
| 105 | } |
Note: See TracBrowser for help on using the browser.
