2640
2674
GST_DEBUG ("mrl = %s", GST_STR_NULL (mrl));
2641
2675
GST_DEBUG ("subtitle_uri = %s", GST_STR_NULL (subtitle_uri));
2644
if (bvw->com->mrl && strcmp (bvw->com->mrl, mrl) == 0) {
2645
GST_DEBUG ("same as current mrl");
2646
/* FIXME: shouldn't we ensure playing state here? */
2650
2677
/* this allows non-URI type of files in the thumbnailer and so on */
2651
g_free (bvw->com->mrl);
2652
if (mrl[0] == '/') {
2653
bvw->com->mrl = g_strdup_printf ("file://%s", mrl);
2678
file = g_file_new_for_commandline_arg (mrl);
2680
/* Only use the URI when FUSE isn't available for a file */
2681
path = g_file_get_path (file);
2683
bvw->com->mrl = g_filename_to_uri (path, NULL, NULL);
2655
if (strchr (mrl, ':')) {
2656
bvw->com->mrl = g_strdup (mrl);
2658
gchar *cur_dir = g_get_current_dir ();
2661
g_set_error (error, BVW_ERROR, BVW_ERROR_GENERIC,
2662
_("Failed to retrieve working directory"));
2665
bvw->com->mrl = g_strdup_printf ("file://%s/%s", cur_dir, mrl);
2686
bvw->com->mrl = g_strdup (mrl);
2689
g_object_unref (file);
2670
2691
if (g_str_has_prefix (mrl, "icy:") != FALSE) {
2671
2692
/* Handle "icy://" URLs from QuickTime */
2672
2693
g_free (bvw->com->mrl);
3745
3758
if (bvw->priv->balance && GST_IS_COLOR_BALANCE (bvw->priv->balance))
3747
const GList *channels_list = NULL;
3748
3760
GstColorBalanceChannel *found_channel = NULL;
3750
channels_list = gst_color_balance_list_channels (bvw->priv->balance);
3752
while (found_channel == NULL && channels_list != NULL) {
3753
/* We search for the right channel corresponding to type */
3754
GstColorBalanceChannel *channel = channels_list->data;
3756
if (type == BVW_VIDEO_BRIGHTNESS && channel &&
3757
g_strrstr (channel->label, "BRIGHTNESS"))
3759
g_object_ref (channel);
3760
found_channel = channel;
3762
else if (type == BVW_VIDEO_CONTRAST && channel &&
3763
g_strrstr (channel->label, "CONTRAST"))
3765
g_object_ref (channel);
3766
found_channel = channel;
3768
else if (type == BVW_VIDEO_SATURATION && channel &&
3769
g_strrstr (channel->label, "SATURATION"))
3771
g_object_ref (channel);
3772
found_channel = channel;
3774
else if (type == BVW_VIDEO_HUE && channel &&
3775
g_strrstr (channel->label, "HUE"))
3777
g_object_ref (channel);
3778
found_channel = channel;
3780
channels_list = g_list_next (channels_list);
3762
found_channel = bvw_get_color_balance_channel (bvw->priv->balance, type);
3783
3764
if (found_channel && GST_IS_COLOR_BALANCE_CHANNEL (found_channel))
3785
int i_value = value * ((double) found_channel->max_value -
3786
found_channel->min_value) / 65535 + found_channel->min_value;
3768
i_value = floor (0.5 + value * ((double) found_channel->max_value -
3769
found_channel->min_value) / 65535 + found_channel->min_value);
3788
3771
GST_DEBUG ("channel %s: set to %d/65535", found_channel->label, value);
3907
3890
gchar *filename;
3909
3892
filename = g_strdup(g_getenv("GST_DVB_CHANNELS_CONF"));
3910
if (filename == NULL) {
3893
if (filename == NULL || g_file_test (filename, G_FILE_TEST_IS_REGULAR) == FALSE) {
3911
3894
gchar *directory;
3913
3895
guint major, minor, micro, nano;
3914
3898
gst_version(&major, &minor, µ, &nano);
3915
3899
directory = g_strdup_printf (".gstreamer-%d.%d", major, minor);
3916
3900
filename = g_build_filename (g_get_home_dir (), directory, "dvb-channels.conf", NULL);
3917
3901
g_free (directory);
3903
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR) == FALSE) {
3905
filename = g_build_filename (g_get_home_dir (), ".xine", "channels.conf", NULL);
3920
3909
return filename;
3923
BaconVideoWidgetCanPlayStatus
3924
bacon_video_widget_can_play (BaconVideoWidget * bvw, TotemDiscMediaType type)
3926
BaconVideoWidgetCanPlayStatus res;
3928
g_return_val_if_fail (bvw != NULL, FALSE);
3929
g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), FALSE);
3930
g_return_val_if_fail (GST_IS_ELEMENT (bvw->priv->play), FALSE);
3933
case MEDIA_TYPE_VCD:
3934
res = BVW_CAN_PLAY_SUCCESS;
3936
case MEDIA_TYPE_DVD: {
3937
if (!gst_default_registry_check_feature_version ("dvdreadsrc", 0, 10, 0)) {
3938
GST_DEBUG ("Missing dvdreadsrc");
3939
res = BVW_CAN_PLAY_MISSING_PLUGINS;
3940
} else if (gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 0) &&
3941
!gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 15)) {
3942
GST_DEBUG ("flupsdemux not new enough for DVD playback");
3943
res = BVW_CAN_PLAY_MISSING_PLUGINS;
3945
res = BVW_CAN_PLAY_SUCCESS;
3949
case MEDIA_TYPE_DVB: {
3952
/* FIXME: change to 0,10,6 once gst-plugins-bad 0.10.6 has been released */
3953
if (!gst_default_registry_check_feature_version ("dvbbasebin", 0, 10, 0) ||
3954
!gst_default_registry_check_feature_version ("mpegtsparse", 0, 10, 0) ||
3955
!gst_default_registry_check_feature_version ("dvbsrc", 0, 10, 0)) {
3956
GST_DEBUG ("Missing one or all of: dvbsrc, dvbbasebin, mpegtsparse");
3957
res = BVW_CAN_PLAY_MISSING_PLUGINS;
3960
if (gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 0) &&
3961
!gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 15)) {
3962
GST_DEBUG ("flupsdemux not new enough for DVB playback");
3963
res = BVW_CAN_PLAY_MISSING_PLUGINS;
3967
filename = bacon_video_widget_get_channels_file ();
3968
if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
3969
res = BVW_CAN_PLAY_SUCCESS;
3971
GST_DEBUG ("no channels file '%s'", filename);
3972
res = BVW_CAN_PLAY_MISSING_CHANNELS;
3977
case MEDIA_TYPE_CDDA:
3979
res = BVW_CAN_PLAY_UNSUPPORTED;
3983
GST_DEBUG ("type=%d, can_play=%d", type, res);
3988
3913
bacon_video_widget_dvb_get_adapter_type (const char *device)
4042
3969
return adapter_type;
3973
bacon_video_widget_get_dvd_mrls (const char *device)
3976
GstElement *element;
3977
gint64 num_titles, i;
3980
element = gst_element_factory_make ("dvdreadsrc", "test_dvdsrc");
3981
if (element == NULL)
3983
/* We need to get the format after instantiating dvdreadsrc, as
3984
* the nick is registered in that class init */
3985
fmt = gst_format_get_by_nick ("title");
3986
g_object_set (element, "device", device, NULL);
3987
if (gst_element_set_state (element, GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS) {
3988
GST_DEBUG ("Couldn't change the state to PAUSED");
3989
gst_object_unref (element);
3992
if (gst_element_query_duration (element, &fmt, &num_titles) == FALSE) {
3993
GST_DEBUG ("Couldn't query the \"duration\" (number of titles)");
3994
gst_element_set_state (element, GST_STATE_NULL);
3995
gst_object_unref (element);
3999
fmt = GST_FORMAT_TIME;
4000
array = g_ptr_array_new ();
4001
for (i = 1 ; i <= num_titles; i++) {
4004
/* Reset to NULL, change the title, and go back to PAUSED */
4005
if (gst_element_set_state (element, GST_STATE_NULL) != GST_STATE_CHANGE_SUCCESS) {
4006
GST_DEBUG ("Couldn't set state to NULL for title %"G_GINT64_FORMAT, i);
4009
g_object_set (element, "title", i, NULL);
4010
if (gst_element_set_state (element, GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS) {
4011
GST_DEBUG ("Couldn't set state for title %"G_GINT64_FORMAT, i);
4015
if (gst_element_query_duration (element, &fmt, &len) == FALSE) {
4016
GST_DEBUG ("Couldnt' query duration for title %"G_GINT64_FORMAT, i);
4019
/* If it's less than 30 seconds long, we kick it out */
4020
if (len >= (30 * GST_SECOND)) {
4021
g_ptr_array_add (array, g_strdup_printf ("dvd://%"G_GINT64_FORMAT, i));
4022
GST_DEBUG ("URI: dvd://%d (time: %" GST_TIME_FORMAT ")",
4023
(gint) i, GST_TIME_ARGS (len));
4027
gst_element_set_state (element, GST_STATE_NULL);
4028
gst_object_unref (element);
4029
if (array->len >= 1)
4030
g_ptr_array_add (array, NULL);
4031
return (char **) g_ptr_array_free (array, FALSE);
4035
bacon_video_widget_get_dvb_mrls (const char *device)
4042
adapter_type = bacon_video_widget_dvb_get_adapter_type (device);
4043
filename = bacon_video_widget_get_channels_file ();
4045
if (g_file_get_contents (filename, &contents, NULL, NULL) != FALSE) {
4046
gchar **lines, *line;
4049
lines = g_strsplit (contents, "\n", 0);
4050
array = g_ptr_array_new ();
4052
for (i = 0; lines[i] != NULL; i++) {
4055
if (line[0] != '#') {
4056
gchar** fields = g_strsplit(line, ":", 0);
4057
if ((g_strv_length (fields) == 13 && adapter_type == 'T') ||
4058
(g_strv_length (fields) == 8 && adapter_type == 'S') ||
4059
(g_strv_length (fields) == 9 && adapter_type == 'C') ||
4060
(g_strv_length (fields) == 6 && adapter_type == 'A')) {
4061
g_ptr_array_add (array, g_strdup_printf("dvb://%s", fields[0]));
4070
if (array->len >= 1)
4071
g_ptr_array_add (array, NULL);
4072
return (char **) g_ptr_array_free (array, FALSE);
4046
bacon_video_widget_get_mrls (BaconVideoWidget * bvw, TotemDiscMediaType type,
4076
bacon_video_widget_get_mrls (BaconVideoWidget * bvw,
4077
TotemDiscMediaType type,
4055
4087
GST_DEBUG ("type = %d", type);
4056
4088
GST_DEBUG ("device = %s", GST_STR_NULL (device));
4091
case MEDIA_TYPE_VCD: {
4092
gchar *uri[] = { NULL, NULL };
4093
uri[0] = g_strdup_printf ("vcd://%s", device);
4094
mrls = g_strdupv (uri);
4098
case MEDIA_TYPE_DVD: {
4099
if (!gst_default_registry_check_feature_version ("dvdreadsrc", 0, 10, 0)) {
4100
GST_DEBUG ("Missing dvdreadsrc");
4101
g_set_error (error, BVW_ERROR, BVW_ERROR_NO_PLUGIN_FOR_FILE,
4102
"XXX Do not use XXX");
4104
} else if (!gst_default_registry_check_feature_version ("mpegpsdemux", 0, 10, 0) &&
4105
gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 0) &&
4106
!gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 15)) {
4107
GST_DEBUG ("flupsdemux not new enough for DVD playback");
4108
g_set_error (error, BVW_ERROR, BVW_ERROR_NO_PLUGIN_FOR_FILE,
4109
"XXX Do not use XXX");
4112
mrls = bacon_video_widget_get_dvd_mrls (device);
4116
case MEDIA_TYPE_DVB: {
4119
if (!gst_default_registry_check_feature_version ("dvbbasebin", 0, 10, 6) ||
4120
!gst_default_registry_check_feature_version ("mpegtsparse", 0, 10, 6) ||
4121
!gst_default_registry_check_feature_version ("dvbsrc", 0, 10, 6)) {
4122
GST_DEBUG ("Missing one or all of: dvbsrc, dvbbasebin, mpegtsparse");
4123
g_set_error (error, BVW_ERROR, BVW_ERROR_NO_PLUGIN_FOR_FILE,
4124
"XXX Do not use XXX");
4127
if (!gst_default_registry_check_feature_version ("mpegpsdemux", 0, 10, 0) &&
4128
gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 0) &&
4129
!gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 15)) {
4130
GST_DEBUG ("flupsdemux not new enough for DVB playback");
4131
g_set_error (error, BVW_ERROR, BVW_ERROR_NO_PLUGIN_FOR_FILE,
4132
"XXX Do not use XXX");
4136
filename = g_strdup_printf ("/dev/dvb/adapter%s/frontend0", device);
4137
if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
4139
g_set_error (error, BVW_ERROR, BVW_ERROR_INVALID_DEVICE,
4140
"XXX Do not use XXX");
4145
filename = bacon_video_widget_get_channels_file ();
4146
if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
4148
mrls = bacon_video_widget_get_dvb_mrls (device);
4150
GST_DEBUG ("no channels file '%s'", filename);
4151
g_set_error (error, BVW_ERROR, BVW_ERROR_FILE_NOT_FOUND,
4152
"XXX Do not use XXX");
4158
case MEDIA_TYPE_CDDA:
4159
g_set_error (error, BVW_ERROR, BVW_ERROR_UNVALID_LOCATION,
4160
"XXX Do not use XXX");
4163
g_assert_not_reached();
4058
4169
g_free (bvw->priv->media_device);
4059
4170
bvw->priv->media_device = g_strdup (device);
4062
case MEDIA_TYPE_VCD: {
4063
gchar *uri[] = { NULL, NULL };
4064
uri[0] = g_strdup_printf ("vcd://%s", device);
4065
mrls = g_strdupv (uri);
4070
case MEDIA_TYPE_DVD: {
4072
GstElement *element;
4073
gint64 num_titles, i;
4076
element = gst_element_factory_make ("dvdreadsrc", "test_dvdsrc");
4077
if (element == NULL)
4079
/* We need to get the format after instantiating dvdreadsrc, as
4080
* the nick is registered in that class init */
4081
fmt = gst_format_get_by_nick ("title");
4082
g_object_set (element, "device", device, NULL);
4083
if (gst_element_set_state (element, GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS) {
4084
GST_DEBUG ("Couldn't change the state to PAUSED");
4085
gst_object_unref (element);
4088
if (gst_element_query_duration (element, &fmt, &num_titles) == FALSE) {
4089
GST_DEBUG ("Couldn't query the \"duration\" (number of titles)");
4090
gst_element_set_state (element, GST_STATE_NULL);
4091
gst_object_unref (element);
4095
fmt = GST_FORMAT_TIME;
4096
array = g_ptr_array_new ();
4097
for (i = 1 ; i <= num_titles; i++) {
4100
/* Reset to NULL, change the title, and go back to PAUSED */
4101
if (gst_element_set_state (element, GST_STATE_NULL) != GST_STATE_CHANGE_SUCCESS) {
4102
GST_DEBUG ("Couldn't set state to NULL for title %"G_GINT64_FORMAT, i);
4105
g_object_set (element, "title", i, NULL);
4106
if (gst_element_set_state (element, GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS) {
4107
GST_DEBUG ("Couldn't set state for title %"G_GINT64_FORMAT, i);
4111
if (gst_element_query_duration (element, &fmt, &len) == FALSE) {
4112
GST_DEBUG ("Couldnt' query duration for title %"G_GINT64_FORMAT, i);
4115
/* If it's less than 30 seconds long, we kick it out */
4116
if (len >= (30 * GST_SECOND)) {
4117
g_ptr_array_add (array, g_strdup_printf ("dvd://%"G_GINT64_FORMAT, i));
4118
GST_DEBUG ("URI: dvd://%d (time: %" GST_TIME_FORMAT ")",
4119
(gint) i, GST_TIME_ARGS (len));
4123
gst_element_set_state (element, GST_STATE_NULL);
4124
gst_object_unref (element);
4125
if (array->len >= 1)
4126
g_ptr_array_add (array, NULL);
4127
mrls = (char **) g_ptr_array_free (array, FALSE);
4130
case MEDIA_TYPE_DVB: {
4136
adapter_type = bacon_video_widget_dvb_get_adapter_type (device);
4137
filename = bacon_video_widget_get_channels_file ();
4139
if (g_file_get_contents (filename, &contents, NULL, NULL) != FALSE) {
4140
gchar **lines, *line;
4143
lines = g_strsplit (contents, "\n", 0);
4144
array = g_ptr_array_new ();
4146
for (i = 0; lines[i] != NULL; i++) {
4149
if (line[0] != '#') {
4150
gchar** fields = g_strsplit(line, ":", 0);
4151
if ((g_strv_length (fields) == 13 && adapter_type == 'T') ||
4152
(g_strv_length (fields) == 8 && adapter_type == 'S') ||
4153
(g_strv_length (fields) == 9 && adapter_type == 'C')) {
4154
g_ptr_array_add (array, g_strdup_printf("dvb://%s", fields[0]));
4163
if (array->len >= 1)
4164
g_ptr_array_add (array, NULL);
4165
mrls = (char **) g_ptr_array_free (array, FALSE);