Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

FrameDisplayer Class Reference

#include <framedisplayer.h>

Collaboration diagram for FrameDisplayer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FrameDisplayer ()
 ~FrameDisplayer ()
void CloseSound ()
void Put (Frame &frame, GtkWidget *drawingarea, gboolean no_audio)
void PutSound (Frame &frame)
void PutGDKRGB32 (Frame &frame, GtkWidget *drawingarea)

Public Attributes

Displayerdisplayer
AudioResample< int16_ne_t,
int16_ne_t > * 
resampler
unsigned char pixels [FRAME_MAX_WIDTH *FRAME_MAX_HEIGHT *4]
kino_sound_taudio_device
gint16 * audio_buffers [4]
gboolean audio_device_avail
gint audio_sampling_rate

Private Attributes

bool prevIsWide

Constructor & Destructor Documentation

FrameDisplayer::FrameDisplayer  ) 
 

Definition at line 35 of file framedisplayer.cc.

References audio_buffers, and DV_AUDIO_MAX_SAMPLES.

00035                                : 
00036     displayer( NULL ), 
00037     resampler( NULL ), 
00038     audio_device( NULL ),
00039     audio_device_avail( FALSE ),
00040     prevIsWide( false )
00041 {
00042     for ( gint i = 0; i < 4; i++ )
00043         audio_buffers[ i ] = ( gint16 * ) malloc( 2 * DV_AUDIO_MAX_SAMPLES * sizeof( gint16 ) );
00044 }

FrameDisplayer::~FrameDisplayer  ) 
 

Definition at line 47 of file framedisplayer.cc.

References audio_buffers, CloseSound(), and displayer.

00048 {
00049     delete displayer;
00050     for ( gint i = 0; i < 4; i++ )
00051         free( audio_buffers[ i ] );
00052     CloseSound();
00053 }


Member Function Documentation

void FrameDisplayer::CloseSound  ) 
 

Definition at line 56 of file framedisplayer.cc.

References audio_device, audio_device_avail, kino_sound_close(), and resampler.

Referenced by ~FrameDisplayer().

00057 {
00058     if ( audio_device_avail )
00059     {
00060         kino_sound_close( audio_device );
00061         audio_device_avail = FALSE;
00062         audio_device = NULL;
00063         delete resampler;
00064         resampler = NULL;
00065     }
00066 }

void FrameDisplayer::Put Frame frame,
GtkWidget *  drawingarea,
gboolean  no_audio
 

Definition at line 96 of file framedisplayer.cc.

References DISPLAY_NONE, DISPLAY_RGB, DISPLAY_YUV, displayer, Displayer::format(), FindDisplayer::getDisplayer(), pixels, prevIsWide, Displayer::put(), and PutSound().

Referenced by videoThread(), and PageCapture::windowMoved().

00097 {
00098     if ( frame.GetWidth() > 0 && frame.GetHeight() > 0 )
00099     {
00100         if ( displayer == NULL )
00101             displayer = FindDisplayer::getDisplayer( drawingarea, frame );
00102         if ( displayer != NULL )
00103         {
00104             DisplayerInput input = DISPLAY_NONE;
00105             switch ( displayer->format() )
00106             {
00107             case DISPLAY_YUV:
00108                 frame.ExtractPreviewYUV( pixels );
00109                 input = DISPLAY_YUV;
00110                 break;
00111             case DISPLAY_RGB:
00112             default:
00113                 frame.ExtractPreviewRGB( pixels );
00114                 input = DISPLAY_RGB;
00115                 break;
00116             }
00117             if ( !no_audio )
00118                 PutSound( frame );
00119             if ( prevIsWide != frame.IsWide() )
00120             {
00121                 prevIsWide = frame.IsWide();
00122                 // The numbers here do not affect the actual display size, only its aspect
00123                 gtk_widget_set_size_request( drawingarea, 320, frame.IsWide() ? 180 : 240 );
00124             }
00125             displayer->put( input, pixels, frame.GetWidth(), frame.GetHeight() );
00126         }
00127     }
00128 }

void FrameDisplayer::PutGDKRGB32 Frame frame,
GtkWidget *  drawingarea
 

void FrameDisplayer::PutSound Frame frame  ) 
 

Definition at line 69 of file framedisplayer.cc.

References audio_device, audio_device_avail, AUDIO_RESAMPLE_SRC_SINC_FASTEST, audio_sampling_rate, Preferences::audioDevice, AudioResampleFactory< input_t, output_t >::createAudioResample(), Preferences::enableAudio, Preferences::getInstance(), kino_sound_init(), kino_sound_new(), kino_sound_player(), AudioResample< input_t, output_t >::output, AudioResample< input_t, output_t >::Resample(), resampler, and AudioResample< input_t, output_t >::size.

Referenced by captureThread(), and Put().

00070 {
00071     static Preferences & prefs = Preferences::getInstance();
00072     if ( prefs.enableAudio )
00073     {
00074         if ( audio_device == NULL )
00075             audio_device = kino_sound_new();
00076         if ( audio_device != NULL )
00077         {
00078             if ( !audio_device_avail && 
00079                     ( audio_sampling_rate = kino_sound_init( frame.decoder->audio, audio_device, prefs.audioDevice ) ) != 0 )
00080             {
00081                 audio_device_avail = TRUE;
00082             }
00083             if ( audio_device_avail )
00084             {
00085                 if ( resampler == NULL )
00086                     resampler = AudioResampleFactory<int16_ne_t,int16_ne_t>::createAudioResample(
00087                                     AUDIO_RESAMPLE_SRC_SINC_FASTEST, audio_sampling_rate );
00088                 resampler->Resample( frame );
00089                 if ( resampler->size )
00090                     kino_sound_player( audio_device, resampler->output, resampler->size );
00091             }
00092         }
00093     }
00094 }


Member Data Documentation

gint16* FrameDisplayer::audio_buffers[4]
 

Definition at line 45 of file framedisplayer.h.

Referenced by FrameDisplayer(), and ~FrameDisplayer().

kino_sound_t* FrameDisplayer::audio_device
 

Definition at line 44 of file framedisplayer.h.

Referenced by CloseSound(), and PutSound().

gboolean FrameDisplayer::audio_device_avail
 

Definition at line 46 of file framedisplayer.h.

Referenced by CloseSound(), and PutSound().

gint FrameDisplayer::audio_sampling_rate
 

Definition at line 47 of file framedisplayer.h.

Referenced by PutSound().

Displayer* FrameDisplayer::displayer
 

Definition at line 38 of file framedisplayer.h.

Referenced by Put(), and ~FrameDisplayer().

unsigned char FrameDisplayer::pixels[FRAME_MAX_WIDTH *FRAME_MAX_HEIGHT *4]
 

Definition at line 41 of file framedisplayer.h.

Referenced by Put().

bool FrameDisplayer::prevIsWide [private]
 

Definition at line 56 of file framedisplayer.h.

Referenced by Put().

AudioResample<int16_ne_t,int16_ne_t>* FrameDisplayer::resampler
 

Definition at line 39 of file framedisplayer.h.

Referenced by CloseSound(), and PutSound().


The documentation for this class was generated from the following files:
Generated on Sun Mar 11 22:12:54 2007 for Kino by  doxygen 1.4.2