+ // Map the argument to the object
+ mlt_consumer this = arg;
+
+ // Get the properties
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
+
+ // Convenience functionality
+ int terminate_on_pause = mlt_properties_get_int( properties, "terminate_on_pause" );
+ int terminated = 0;
+
+ // Frame and size
+ mlt_frame frame = NULL;
+
+ int video_off = mlt_properties_get_int( properties, "video_off" );
+ int audio_off = mlt_properties_get_int( properties, "audio_off" );
+
+ // Loop while running
+ while( !terminated && mlt_properties_get_int( properties, "running" ) )
+ {
+ // Get the frame
+ frame = mlt_consumer_rt_frame( this );
+
+ // Check for termination
+ if ( terminate_on_pause && frame != NULL )
+ terminated = mlt_properties_get_double( MLT_FRAME_PROPERTIES( frame ), "_speed" ) == 0.0;
+
+ // Check that we have a frame to work with
+ if ( frame )
+ {
+ int width = 0, height = 0;
+ int frequency = mlt_properties_get_int( properties, "frequency" );
+ int channels = mlt_properties_get_int( properties, "channels" );
+ int samples = 0;
+ mlt_image_format iformat = mlt_image_yuv422;
+ mlt_audio_format aformat = mlt_audio_s16;
+ uint8_t *buffer;
+
+ if ( !video_off )
+ mlt_frame_get_image( frame, &buffer, &iformat, &width, &height, 0 );
+ if ( !audio_off )
+ mlt_frame_get_audio( frame, (void**) &buffer, &aformat, &frequency, &channels, &samples );
+
+ // Close the frame
+ mlt_events_fire( properties, "consumer-frame-show", frame, NULL );
+ mlt_frame_close( frame );
+ }
+ }
+ output_xml( this );
+
+ // Indicate that the consumer is stopped
+ mlt_properties_set_int( properties, "running", 0 );
+ mlt_consumer_stopped( this );
+
+ return NULL;