[svn r100] del mmyth_videoplayer* trunk
authorleo_sobral
Wed Nov 22 12:55:16 2006 +0000 (2006-11-22)
branchtrunk
changeset 99404189e73f8e
parent 98 d0f379fc4173
child 100 f4be69980934
[svn r100] del mmyth_videoplayer*
maemo-ui/src/mmyth_tvplayer.c
maemo-ui/src/mmyth_videoplayer.c
maemo-ui/src/mmyth_videoplayer.h
     1.1 --- a/maemo-ui/src/mmyth_tvplayer.c	Wed Nov 22 00:16:33 2006 +0000
     1.2 +++ b/maemo-ui/src/mmyth_tvplayer.c	Wed Nov 22 12:55:16 2006 +0000
     1.3 @@ -254,7 +254,7 @@
     1.4  
     1.5      /* Gstreamer Video elements */
     1.6      videoqueue1 = gst_element_factory_make ("queue", "video-queue1");
     1.7 -    videodec = gst_element_factory_make ("divxdec", "video-decoder");
     1.8 +    videodec = gst_element_factory_make ("ffdec_mpeg4", "video-decoder");
     1.9      videoqueue2 = gst_element_factory_make ("queue", "video-queue2");
    1.10      videocolortrs = gst_element_factory_make ("ffmpegcolorspace", "image-color-transforms");
    1.11  
     2.1 --- a/maemo-ui/src/mmyth_videoplayer.c	Wed Nov 22 00:16:33 2006 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,369 +0,0 @@
     2.4 -
     2.5 -#include <gst/gst.h>
     2.6 -#include <gtk/gtk.h>
     2.7 -#include <gdk/gdkx.h>
     2.8 -#include <gst/interfaces/xoverlay.h>
     2.9 -#include <unistd.h>
    2.10 -
    2.11 -#include "mmyth_ui.h"
    2.12 -#include "mmyth_videoplayer.h"
    2.13 -#include "mmyth_sdpreader.h"
    2.14 -
    2.15 -#include "esg_database.h"
    2.16 -
    2.17 -#include "ipd_demux.h"
    2.18 -#include "ipd_network.h"
    2.19 -
    2.20 -#ifdef INDT_IP_DECAPSULATOR
    2.21 -#include <sys/types.h>
    2.22 -#include <signal.h>
    2.23 -#endif
    2.24 -
    2.25 -/* Global flag/semaphore to control IP decapsulator threads */
    2.26 -gboolean state_keep_running = 0;
    2.27 -
    2.28 -
    2.29 -typedef struct _GstPlayerWindowStateChange
    2.30 -{
    2.31 -    GstElement *play;
    2.32 -    GstState old_state, new_state;
    2.33 -    MMythUi *mmyth_ui;
    2.34 -} GstPlayerWindowStateChange;
    2.35 -
    2.36 -typedef struct _GstPlayerWindowTagFound
    2.37 -{
    2.38 -    GstElement *play;
    2.39 -    GstTagList *taglist;
    2.40 -    MMythUi *mmyth_ui;
    2.41 -} GstPlayerWindowTagFound;
    2.42 -
    2.43 -
    2.44 -GstElement *gst_pipeline, *gst_decoder, *gst_videosink;
    2.45 -
    2.46 -static gboolean idle_state (gpointer data);
    2.47 -
    2.48 -static gboolean
    2.49 -bus_call (GstBus * bus, GstMessage * msg, gpointer data)
    2.50 -{
    2.51 -    MMythUi *mmyth_ui = (MMythUi *) data;
    2.52 -    GMainLoop *loop = mmyth_ui->loop;
    2.53 -
    2.54 -    switch (GST_MESSAGE_TYPE (msg)) {
    2.55 -        case GST_MESSAGE_EOS:
    2.56 -
    2.57 -            if (mmyth_ui->idle_id != 0) {
    2.58 -                g_source_remove (mmyth_ui->idle_id);
    2.59 -                mmyth_ui->idle_id = 0;
    2.60 -            }
    2.61 -
    2.62 -            //g_idle_add ((GSourceFunc) idle_eos, data);
    2.63 -            gst_element_set_state (GST_ELEMENT (GST_MESSAGE_SRC (msg)),
    2.64 -                                   GST_STATE_READY);
    2.65 -            break;
    2.66 -        case GST_MESSAGE_ERROR:{
    2.67 -                gchar *debug;
    2.68 -                GError *err;
    2.69 -
    2.70 -                gst_message_parse_error (msg, &err, &debug);
    2.71 -                g_free (debug);
    2.72 -
    2.73 -                printf ("Error: %s\n", err->message);
    2.74 -                g_error_free (err);
    2.75 -
    2.76 -                g_main_loop_quit (loop);
    2.77 -            }
    2.78 -            break;
    2.79 -        case GST_MESSAGE_STATE_CHANGED:{
    2.80 -                GstState oldstate;
    2.81 -                GstState newstate;
    2.82 -                GstState pending;
    2.83 -                GstPlayerWindowStateChange *st =
    2.84 -                    g_new (GstPlayerWindowStateChange, 1);
    2.85 -
    2.86 -                gst_message_parse_state_changed (msg,
    2.87 -                                                 &oldstate,
    2.88 -                                                 &newstate, &pending);
    2.89 -
    2.90 -                st->play = mmyth_ui->play;
    2.91 -                gst_object_ref (GST_OBJECT (mmyth_ui->play));
    2.92 -                st->old_state = oldstate;
    2.93 -                st->new_state = newstate;
    2.94 -
    2.95 -                st->mmyth_ui = mmyth_ui;
    2.96 -
    2.97 -                /* State debug messages */
    2.98 -                printf ("oldstate = %s, newstate = %s, pendingstate = %s\n",
    2.99 -                        gst_element_state_get_name (oldstate),
   2.100 -                        gst_element_state_get_name (newstate),
   2.101 -                        gst_element_state_get_name (pending));
   2.102 -
   2.103 -                g_idle_add ((GSourceFunc) idle_state, st);
   2.104 -
   2.105 -            }
   2.106 -            break;
   2.107 -        default:
   2.108 -            printf (gst_message_type_get_name (GST_MESSAGE_TYPE (msg)));
   2.109 -            printf ("\n");
   2.110 -            break;
   2.111 -    }
   2.112 -
   2.113 -    return TRUE;
   2.114 -}
   2.115 -
   2.116 -
   2.117 -static gboolean
   2.118 -cb_iterate (gpointer data)
   2.119 -{
   2.120 -    MMythUi *mmyth_ui = (MMythUi *) data;
   2.121 -    //gboolean res;
   2.122 -
   2.123 -    g_main_loop_run (mmyth_ui->loop);
   2.124 -/*
   2.125 -	if (!GST_FLAG_IS_SET (mmyth_ui->play, GST_BIN_SELF_SCHEDULABLE)) {
   2.126 -    	res = gst_bin_iterate (GST_BIN (mmyth_ui->play));
   2.127 -	} else {
   2.128 -    	g_usleep (100);
   2.129 -		res = (gst_element_get_state (mmyth_ui->play) == GST_STATE_PLAYING);
   2.130 -	}
   2.131 -
   2.132 -	if (!res)
   2.133 -    	mmyth_ui->idle_id = 0;
   2.134 -    	
   2.135 -    return res;
   2.136 -*/
   2.137 -    return FALSE;
   2.138 -
   2.139 -}
   2.140 -
   2.141 -static gboolean
   2.142 -idle_state (gpointer data)
   2.143 -{
   2.144 -    GstPlayerWindowStateChange *st = data;
   2.145 -
   2.146 -    if (st->old_state == GST_STATE_PLAYING) {
   2.147 -        if (st->mmyth_ui->idle_id != 0) {
   2.148 -            g_source_remove (st->mmyth_ui->idle_id);
   2.149 -            st->mmyth_ui->idle_id = 0;
   2.150 -        }
   2.151 -    }
   2.152 -    else if (st->new_state == GST_STATE_PLAYING) {
   2.153 -        if (st->mmyth_ui->idle_id != 0)
   2.154 -            g_source_remove (st->mmyth_ui->idle_id);
   2.155 -
   2.156 -        st->mmyth_ui->idle_id = g_idle_add (cb_iterate, st->mmyth_ui);
   2.157 -    }
   2.158 -
   2.159 -    /* new movie loaded? */
   2.160 -    if (st->old_state == GST_STATE_READY && st->new_state > GST_STATE_READY) {
   2.161 -
   2.162 -        /* gboolean have_video = FALSE; */
   2.163 -
   2.164 -        gtk_widget_show (st->mmyth_ui->videow);
   2.165 -
   2.166 -        gtk_window_resize (GTK_WINDOW (st->mmyth_ui->main_window), 1, 1);
   2.167 -
   2.168 -    }
   2.169 -
   2.170 -    /* discarded movie? */
   2.171 -    if (st->old_state > GST_STATE_READY && st->new_state == GST_STATE_READY) {
   2.172 -
   2.173 -        if (st->mmyth_ui->tagcache) {
   2.174 -            gst_tag_list_free (st->mmyth_ui->tagcache);
   2.175 -            st->mmyth_ui->tagcache = NULL;
   2.176 -        }
   2.177 -    }
   2.178 -
   2.179 -    gst_object_unref (GST_OBJECT (st->play));
   2.180 -    //g_object_unref (G_OBJECT (st->win));
   2.181 -    g_free (st);
   2.182 -
   2.183 -    /* once */
   2.184 -    return FALSE;
   2.185 -}
   2.186 -
   2.187 -
   2.188 -
   2.189 -static gboolean
   2.190 -expose (GtkWidget * widget, GdkEventExpose * event, gpointer user_data)
   2.191 -{
   2.192 -    MMythUi *mmyth_ui = (MMythUi *) user_data;
   2.193 -
   2.194 -    gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (mmyth_ui->videosink),
   2.195 -                                  GDK_WINDOW_XWINDOW (mmyth_ui->videow->
   2.196 -                                                      window));
   2.197 -    return TRUE;
   2.198 -}
   2.199 -
   2.200 -
   2.201 -void
   2.202 -mmyth_player_init (MMythUi * mmyth_ui)
   2.203 -{
   2.204 -    GstElement *play;
   2.205 -    GstElement *source, *parser, *decoder, *videosink;
   2.206 -
   2.207 -    play = gst_pipeline_new ("video-player");
   2.208 -    source = gst_element_factory_make ("udpsrc", "file-source");
   2.209 -    parser = gst_element_factory_make ("rtph263pdepay", "rtp-demux");
   2.210 -    decoder = gst_element_factory_make ("ffdec_h263", "mpeg-decoder");
   2.211 -    videosink = gst_element_factory_make ("xvimagesink", "image-output");
   2.212 -    gst_pipeline = play;
   2.213 -    gst_decoder = decoder;
   2.214 -    gst_videosink = videosink;
   2.215 -
   2.216 -    if (!(gst_pipeline && source && parser && decoder && videosink)) {
   2.217 -        /* FIXME: hanlde the error correctly */
   2.218 -        /* video_alignment is not being created (below) 
   2.219 -           and is causing problems to the ui */
   2.220 -        g_print ("GstElement creation error!\n");
   2.221 -        return;
   2.222 -    }
   2.223 -
   2.224 -    g_object_set (G_OBJECT (videosink), "sync", FALSE, NULL);
   2.225 -
   2.226 -    gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (gst_pipeline)),
   2.227 -                       bus_call, mmyth_ui);
   2.228 -
   2.229 -    gst_bin_add_many (GST_BIN (gst_pipeline), source, parser, decoder,
   2.230 -                      videosink, NULL);
   2.231 -
   2.232 -    {
   2.233 -        GstCaps *rtpcaps = gst_caps_new_simple ("application/x-rtp", NULL);
   2.234 -        gst_element_link_filtered(source, parser, rtpcaps);
   2.235 -    }
   2.236 -    
   2.237 -    gst_element_link_many (/*source,*/ parser, decoder, videosink, NULL);
   2.238 -
   2.239 -    /* actual window */
   2.240 -    mmyth_ui->play = play;
   2.241 -    mmyth_ui->videosink = videosink;
   2.242 -    mmyth_ui->udpsource = source;
   2.243 -
   2.244 -    g_object_ref (mmyth_ui->play);
   2.245 -    g_object_ref (mmyth_ui->videosink);
   2.246 -
   2.247 -    /* video widget */
   2.248 -    //mmyth_ui->videow = gst_player_video_new (videosink, play);
   2.249 -    mmyth_ui->videow = gtk_drawing_area_new ();
   2.250 -    gtk_widget_set_size_request (mmyth_ui->videow, 300, 240);
   2.251 -
   2.252 -    mmyth_ui->logo = gdk_pixbuf_new_from_file ("logo.png", NULL);
   2.253 -
   2.254 -
   2.255 -    mmyth_ui->video_alignment = gtk_alignment_new (0.5, 0.5, 0, 0);
   2.256 -    gtk_widget_hide (mmyth_ui->video_alignment);
   2.257 -
   2.258 -    gtk_container_add (GTK_CONTAINER (mmyth_ui->video_alignment),
   2.259 -                       mmyth_ui->videow);
   2.260 -
   2.261 -    g_signal_connect (mmyth_ui->videow, "expose-event", G_CALLBACK (expose),
   2.262 -                      mmyth_ui);
   2.263 -    //g_signal_connect(mmyth_ui->videow, "size_request", G_CALLBACK(cb_preferred_video_size), mmyth_ui);
   2.264 -
   2.265 -
   2.266 -    g_object_ref (mmyth_ui->videow);
   2.267 -    g_object_ref (mmyth_ui->video_alignment);
   2.268 -
   2.269 -    //gnome_app_set_contents (app, videow);
   2.270 -    //gtk_widget_show (mmyth_ui->videow);
   2.271 -
   2.272 -//fail:
   2.273 -//  gst_object_unref (GST_OBJECT (play));
   2.274 -//  return NULL;  
   2.275 -
   2.276 -}
   2.277 -
   2.278 -void
   2.279 -mmyth_player_stop (MMythUi * mmyth_ui)
   2.280 -{
   2.281 -    gst_element_set_state (mmyth_ui->play, GST_STATE_NULL);
   2.282 -
   2.283 -    if(mmyth_ui->videow != NULL)
   2.284 -        gtk_widget_hide (mmyth_ui->videow);
   2.285 -
   2.286 -    /* Disable IP Decapsulator playing threads */
   2.287 -    state_keep_running = FALSE;	
   2.288 -
   2.289 -}
   2.290 -
   2.291 -static gboolean
   2.292 -idle_play (gpointer data)
   2.293 -{
   2.294 -    MMythUi *mmyth_ui = (MMythUi *) data;
   2.295 -
   2.296 -    sleep (2);
   2.297 -
   2.298 -    gst_element_set_state (mmyth_ui->play, GST_STATE_PLAYING);
   2.299 -
   2.300 -    return FALSE;
   2.301 -}
   2.302 -
   2.303 -
   2.304 -/* Run IP decapsulator play function in a new thread. The thread is finished setting the
   2.305 - * semaphore "state_keep_running" to FALSE*/
   2.306 -gpointer
   2.307 -run_ipd(gpointer data)
   2.308 -{
   2.309 -    GString *ip_addr = (GString*) data;
   2.310 -
   2.311 -	state_keep_running = TRUE;
   2.312 -
   2.313 -	printf("Inside thread\n");
   2.314 -
   2.315 -	ipd_mpe_play_section (ip_addr->str, &state_keep_running);
   2.316 -
   2.317 -	return 0;
   2.318 -}
   2.319 -
   2.320 -void
   2.321 -mmyth_play_channel (MMythUi * mmyth_ui, gint service_number)
   2.322 -{
   2.323 -	ESGDatabase *esg_db;
   2.324 -    DVBHService *service;
   2.325 -	SDPData sdp_data;
   2.326 -	GString *service_ip_addr;
   2.327 -	
   2.328 -	/* First verifies if there is a tuned network */
   2.329 -	if ( !ipd_network_is_tuned() ) {
   2.330 -		/* FIXME: show alert and handle this error */
   2.331 -        g_warning ("Play not possible, network not tuned");
   2.332 -		return;
   2.333 -	}
   2.334 -
   2.335 -    esg_db = esg_database_get_instance();
   2.336 -    /* Gets the service structure */
   2.337 -    service = (DVBHService *) esg_database_get_service_from_number
   2.338 -                                 (esg_db, service_number);
   2.339 -
   2.340 -	/* Verifies if sdp fragment exists to this service */
   2.341 -	if ( service->sdp_file == NULL ) {
   2.342 -		/* FIXME: Implement error handling */
   2.343 -        g_warning ("SDP fragment not available to access service");
   2.344 -		return;
   2.345 -    }
   2.346 -	
   2.347 -	/* Parses the sdp to get ipv6 address and port */
   2.348 -	mmyth_sdp_parse_file (service->sdp_file->str, &sdp_data);
   2.349 -
   2.350 -    /* Sets the gstreamer properties acording to the service access address */
   2.351 -	/* FIXME: Develop sdp_bin in gstreamer to give sdp file as pipeline config */
   2.352 -    g_object_set (G_OBJECT (mmyth_ui->udpsource), "multicast_group",
   2.353 -                  sdp_data.ip_addr->str, NULL);
   2.354 -    g_object_set (G_OBJECT (mmyth_ui->udpsource), "port", sdp_data.video_port, NULL);
   2.355 -
   2.356 -    /* Shows the video widget on screen */
   2.357 -    mmyth_ui_set_widget (mmyth_ui, mmyth_ui->video_uicommon);
   2.358 -
   2.359 -    gtk_widget_show (mmyth_ui->videow);
   2.360 -    gtk_widget_queue_draw (mmyth_ui->videow);
   2.361 -
   2.362 -#ifdef INDT_IP_DECAPSULATOR
   2.363 -    /* Will be dealocated in run_ipd */	
   2.364 -	service_ip_addr = g_string_new (sdp_data.ip_addr->str);
   2.365 -	
   2.366 -	/* Requests the IP decapsulator to play the channel stream*/
   2.367 -	g_thread_create (run_ipd, (gpointer) service_ip_addr, FALSE, NULL);
   2.368 -#endif
   2.369 -		
   2.370 -    //gst_element_set_state (mmyth_ui->play, GST_STATE_PLAYING);
   2.371 -    g_idle_add (idle_play, mmyth_ui);
   2.372 -}
     3.1 --- a/maemo-ui/src/mmyth_videoplayer.h	Wed Nov 22 00:16:33 2006 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,12 +0,0 @@
     3.4 -#ifndef MMYTH_VIDEOPLAYER_H_
     3.5 -#define MMYTH_VIDEOPLAYER_H_
     3.6 -
     3.7 -#include "mmyth_ui.h"
     3.8 -
     3.9 -void mmyth_player_init (MMythUi * mmyth_ui);
    3.10 -void mmyth_player_stop (MMythUi * mmyth_ui);
    3.11 -
    3.12 -void mmyth_play_channel (MMythUi * mmyth_ui, gint service_id);
    3.13 -
    3.14 -
    3.15 -#endif /* MMYTH_VIDEOPLAYER_H_ */