121
124
* Return value: new #RBTrackTransferBatch object
123
126
RBTrackTransferBatch *
124
rb_track_transfer_batch_new (GList *media_types,
125
const char * const *media_types_strv,
127
rb_track_transfer_batch_new (GstEncodingTarget *target,
127
129
GObject *destination)
131
/* can't specify both, can specify neither */
132
g_assert (media_types == NULL || media_types_strv == NULL);
134
if (media_types != NULL) {
135
obj = g_object_new (RB_TYPE_TRACK_TRANSFER_BATCH,
136
"media-types", media_types,
138
"destination", destination,
141
obj = g_object_new (RB_TYPE_TRACK_TRANSFER_BATCH,
142
"media-types-strv", &media_types_strv,
144
"destination", destination,
133
obj = g_object_new (RB_TYPE_TRACK_TRANSFER_BATCH,
134
"encoding-target", target,
136
"destination", destination,
147
138
return RB_TRACK_TRANSFER_BATCH (obj);
160
151
batch->priv->entries = g_list_append (batch->priv->entries, rhythmdb_entry_ref (entry));
155
select_profile_for_entry (RBTrackTransferBatch *batch, RhythmDBEntry *entry, GstEncodingProfile **rprofile, gboolean allow_missing)
157
/* probably want a way to pass in some policy about lossless encoding
158
* here. possibilities:
159
* - convert everything to lossy
160
* - if transcoding is required, use lossy
161
* - keep lossless encoded files lossless
162
* - if transcoding is required, use lossless
163
* - convert everything to lossless
165
* of course this only applies to targets that include lossless profiles..
168
const char *media_type = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MEDIA_TYPE);
171
for (p = gst_encoding_target_get_profiles (batch->priv->target); p != NULL; p = p->next) {
172
GstEncodingProfile *profile = GST_ENCODING_PROFILE (p->data);
173
char *profile_media_type;
176
if (g_str_has_prefix (media_type, "audio/x-raw") == FALSE &&
177
rb_gst_media_type_matches_profile (profile, media_type)) {
178
/* source file is already in a supported encoding, so just copy it */
184
/* ignore lossless encodings for now */
185
profile_media_type = rb_gst_encoding_profile_get_media_type (profile);
186
if (profile_media_type == NULL) {
187
if (g_str_has_prefix (media_type, "audio/x-raw")) {
190
} else if (rb_gst_media_type_is_lossless (profile_media_type)) {
192
} else if (allow_missing == FALSE) {
193
if (g_list_find (batch->priv->missing_plugin_profiles, profile)) {
198
if (skip == FALSE && *rprofile == NULL) {
201
g_free (profile_media_type);
204
return (*rprofile != NULL);
164
* rb_track_transfer_batch_check_media_types:
208
* rb_track_transfer_batch_check_profiles:
165
209
* @batch: a #RBTrackTransferBatch
210
* @missing_plugin_profiles: holds a #GList of #GstEncodingProfiles on return
211
* @error_count: holds the number of entries that cannot be transferred on return
167
213
* Checks that all entries in the batch can be transferred in a format
168
* supported by the destination.
214
* supported by the destination. If no encoding profile is available for
215
* some entries, but installing additional plugins could make a profile
216
* available, a list of profiles that require additional plugins is returned.
170
* Return value: number of entries that cannot be transferred
218
* Return value: %TRUE if some entries can be transferred without additional plugins
173
rb_track_transfer_batch_check_media_types (RBTrackTransferBatch *batch)
221
rb_track_transfer_batch_check_profiles (RBTrackTransferBatch *batch, GList **missing_plugin_profiles, int *error_count)
175
223
RBEncoder *encoder = rb_encoder_new ();
224
gboolean ret = FALSE;
227
rb_debug ("checking profiles");
229
/* first, figure out which profiles that we care about would require additional plugins to use */
230
g_list_free (batch->priv->missing_plugin_profiles);
231
batch->priv->missing_plugin_profiles = NULL;
233
for (l = gst_encoding_target_get_profiles (batch->priv->target); l != NULL; l = l->next) {
234
GstEncodingProfile *profile = GST_ENCODING_PROFILE (l->data);
235
char *profile_media_type;
236
profile_media_type = rb_gst_encoding_profile_get_media_type (profile);
237
if ((rb_gst_media_type_is_lossless (profile_media_type) == FALSE) &&
238
rb_encoder_get_missing_plugins (encoder, profile, NULL, NULL)) {
239
batch->priv->missing_plugin_profiles = g_list_append (batch->priv->missing_plugin_profiles, profile);
241
g_free (profile_media_type);
243
g_object_unref (encoder);
245
rb_debug ("have %d profiles with missing plugins", g_list_length (batch->priv->missing_plugin_profiles));
179
247
for (l = batch->priv->entries; l != NULL; l = l->next) {
180
248
RhythmDBEntry *entry = (RhythmDBEntry *)l->data;
181
/* check that we can transfer this entry to the device */
182
if (rb_encoder_get_media_type (encoder,
184
batch->priv->media_types,
249
GstEncodingProfile *profile;
252
if (select_profile_for_entry (batch, entry, &profile, FALSE) == TRUE) {
253
if (profile != NULL) {
254
rb_debug ("found profile %s for %s",
255
gst_encoding_profile_get_name (profile),
256
rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION));
258
rb_debug ("copying entry %s", rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION));
265
if (select_profile_for_entry (batch, entry, &profile, TRUE) == FALSE) {
187
266
rb_debug ("unable to transfer %s (media type %s)",
188
267
rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION),
189
rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MIMETYPE));
268
rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MEDIA_TYPE));
270
rb_debug ("require additional plugins to transfer %s (media type %s)",
271
rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION),
272
rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MEDIA_TYPE));
273
if (*missing_plugin_profiles == NULL) {
274
*missing_plugin_profiles = g_list_copy (batch->priv->missing_plugin_profiles);
193
g_object_unref (encoder);
443
550
fraction = 1.0 / ((double)count);
450
if (rb_encoder_get_media_type (batch->priv->current_encoder,
452
batch->priv->media_types,
454
&extension) == FALSE) {
455
rb_debug ("skipping entry %s, can't find a destination format",
554
if (select_profile_for_entry (batch, entry, &profile, FALSE) == FALSE) {
555
rb_debug ("skipping entry %s, can't find an encoding profile",
456
556
rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION));
457
557
rhythmdb_entry_unref (entry);
458
558
batch->priv->total_fraction += fraction;
562
if (profile != NULL) {
563
media_type = rb_gst_encoding_profile_get_media_type (profile);
564
extension = g_strdup (rb_gst_media_type_to_extension (media_type));
566
media_type = rhythmdb_entry_dup_string (entry, RHYTHMDB_PROP_MEDIA_TYPE);
567
extension = g_strdup (rb_gst_media_type_to_extension (media_type));
568
if (extension == NULL) {
569
extension = get_extension_from_location (entry);
462
573
g_free (batch->priv->current_dest_uri);
463
574
batch->priv->current_dest_uri = NULL;
464
575
g_signal_emit (batch, signals[GET_DEST_URI], 0,
641
749
object_class->dispose = impl_dispose;
644
* RBTrackTransferBatch:media-types
646
* Array of media type strings describing the acceptable
647
* destination formats. If NULL, no format conversion will
650
g_object_class_install_property (object_class,
651
PROP_MEDIA_TYPES_STRV,
652
g_param_spec_boxed ("media-types-strv",
654
"Set of allowable destination media types",
656
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
658
* RBTrackTransferBatch:media-types
660
* GList of media type strings describing the acceptable
661
* destination formats. If NULL, no format conversion will
664
g_object_class_install_property (object_class,
666
g_param_spec_pointer ("media-types",
668
"Set of allowable destination media types",
669
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
752
* RBTrackTransferBatch:encoding-target
754
* A GstEncodingTarget describing allowable target formats.
755
* If NULL, the default set of profiles will be used.
757
g_object_class_install_property (object_class,
758
PROP_ENCODING_TARGET,
759
gst_param_spec_mini_object ("encoding-target",
762
GST_TYPE_ENCODING_TARGET,
763
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
671
765
* RBTrackTransferBatch:source