~mfisch/brasero/update-to-3.8.0

« back to all changes in this revision

Viewing changes to libbrasero-burn/brasero-caps-session.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Moog
  • Date: 2009-07-28 01:12:27 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 46.
  • Revision ID: james.westby@ubuntu.com-20090728011227-tiva9yorc5d1r5hs
Tags: upstream-2.27.5
ImportĀ upstreamĀ versionĀ 2.27.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
                return BRASERO_BURN_NOT_SUPPORTED;
130
130
        }
131
131
 
132
 
        /* This is a special case that is in MMC specs:
133
 
         * DVD-RW sequential must be fully blanked
134
 
         * if we really want multisession support. */
135
 
        if (BRASERO_MEDIUM_IS (media, BRASERO_MEDIUM_DVDRW)
136
 
        && (session_flags & BRASERO_BURN_FLAG_MULTI)) {
137
 
                if (compulsory_flags & BRASERO_BURN_FLAG_FAST_BLANK) {
138
 
                        BRASERO_BURN_LOG ("fast media blanking only supported but multisession required for DVDRW");
139
 
                        return BRASERO_BURN_NOT_SUPPORTED;
140
 
                }
141
 
 
142
 
                supported_flags &= ~BRASERO_BURN_FLAG_FAST_BLANK;
143
 
 
144
 
                BRASERO_BURN_LOG ("removed fast blank for a DVDRW with multisession");
145
 
        }
146
 
 
147
132
        if (supported)
148
133
                *supported = supported_flags;
149
134
        if (compulsory)
152
137
        return BRASERO_BURN_OK;
153
138
}
154
139
 
155
 
/**
156
 
 * brasero_burn_session_get_blank_flags:
157
 
 * @session: a #BraseroBurnSession
158
 
 * @supported: a #BraseroBurnFlag
159
 
 * @compulsory: a #BraseroBurnFlag
160
 
 *
161
 
 * Given the various parameters stored in @session,
162
 
 * stores in @supported and @compulsory, the flags
163
 
 * that can be used (@supported) and must be used
164
 
 * (@compulsory) when blanking the medium in the
165
 
 * #BraseroDrive (set with brasero_burn_session_set_burner ()).
166
 
 *
167
 
 * Return value: a #BraseroBurnResult.
168
 
 * BRASERO_BURN_OK if the retrieval was successful.
169
 
 * BRASERO_BURN_ERR otherwise.
170
 
 **/
171
 
 
172
140
BraseroBurnResult
173
141
brasero_burn_session_get_blank_flags (BraseroBurnSession *session,
174
142
                                      BraseroBurnFlag *supported,
217
185
                return BRASERO_BURN_NOT_SUPPORTED;
218
186
        }
219
187
 
220
 
        /* This is a special case from MMC: DVD-RW sequential
221
 
         * can only be multisession is they were fully blanked
222
 
         * so if there are the two flags, abort. */
223
 
        if (BRASERO_MEDIUM_IS (media, BRASERO_MEDIUM_DVDRW)
224
 
        &&  (flags & BRASERO_BURN_FLAG_MULTI)
225
 
        &&  (flags & BRASERO_BURN_FLAG_FAST_BLANK)) {
226
 
                BRASERO_BURN_LOG ("fast media blanking only supported but multisession required for DVDRW");
227
 
                return BRASERO_BURN_NOT_SUPPORTED;
228
 
        }
229
 
 
230
188
        for (iter = self->priv->caps_list; iter; iter = iter->next) {
231
189
                BraseroCaps *caps;
232
190
                GSList *links;
274
232
        return BRASERO_BURN_NOT_SUPPORTED;
275
233
}
276
234
 
277
 
/**
278
 
 * brasero_burn_session_can_blank:
279
 
 * @session: a #BraseroBurnSession
280
 
 *
281
 
 * Given the various parameters stored in @session, this
282
 
 * function checks whether the medium in the
283
 
 * #BraseroDrive (set with brasero_burn_session_set_burner ())
284
 
 * can be blanked.
285
 
 *
286
 
 * Return value: a #BraseroBurnResult.
287
 
 * BRASERO_BURN_OK if it is possible.
288
 
 * BRASERO_BURN_ERR otherwise.
289
 
 **/
290
 
 
291
235
BraseroBurnResult
292
236
brasero_burn_session_can_blank (BraseroBurnSession *session)
293
237
{
314
258
        return result;
315
259
}
316
260
 
 
261
/**
 
262
 *
 
263
 */
 
264
 
317
265
static void
318
266
brasero_caps_link_get_record_flags (BraseroCapsLink *link,
319
267
                                    BraseroMedia media,
654
602
                                       io_flags);
655
603
}
656
604
 
657
 
/**
658
 
 * brasero_burn_session_input_supported:
659
 
 * @session: a #BraseroBurnSession
660
 
 * @input: a #BraseroTrackType
661
 
 * @use_flags: a #gboolean
662
 
 *
663
 
 * Given the various parameters stored in @session, this
664
 
 * function checks whether a session with the data type
665
 
 * @type could be burnt to the medium in the #BraseroDrive (set 
666
 
 * through brasero_burn_session_set_burner ()).
667
 
 * If @use_flags is TRUE, then flags are taken into account
668
 
 * and are not if it is FALSE.
669
 
 *
670
 
 * Return value: a #BraseroBurnResult.
671
 
 * BRASERO_BURN_OK if it is possible.
672
 
 * BRASERO_BURN_ERR otherwise.
673
 
 **/
674
 
 
675
605
BraseroBurnResult
676
606
brasero_burn_session_input_supported (BraseroBurnSession *session,
677
607
                                      BraseroTrackType *input,
731
661
        return BRASERO_BURN_OK;
732
662
}
733
663
 
734
 
/**
735
 
 * brasero_burn_session_output_supported:
736
 
 * @session: a #BraseroBurnSession *
737
 
 * @output: a #BraseroTrackType *
738
 
 *
739
 
 * Make sure that the image type or medium type defined in @output can be
740
 
 * created/burnt given the parameters and the current data set in @session.
741
 
 *
742
 
 * Return value: BRASERO_BURN_OK if the medium type or the image type can be used as an output.
743
 
 **/
744
664
BraseroBurnResult
745
665
brasero_burn_session_output_supported (BraseroBurnSession *session,
746
666
                                       BraseroTrackType *output)
788
708
        return BRASERO_BURN_OK;
789
709
}
790
710
 
791
 
/* This function is not public API yet because it was too
792
 
 * late; so use it internally for now. It's mainly for 
793
 
 * convenience.*/
794
 
gboolean
795
 
brasero_drive_can_write_media (BraseroDrive *drive,
796
 
                               BraseroMedia media);
797
 
 
798
711
/**
799
712
 * This is only to be used in case one wants to copy using the same drive.
800
713
 * It determines the possible middle image type.
803
716
static BraseroBurnResult
804
717
brasero_burn_caps_is_session_supported_same_src_dest (BraseroBurnCaps *self,
805
718
                                                      BraseroBurnSession *session,
806
 
                                                      BraseroTrackType *tmp_type,
807
719
                                                      gboolean use_flags)
808
720
{
809
721
        GSList *iter;
810
 
        BraseroDrive *burner;
811
722
        BraseroTrackType input;
812
723
        BraseroTrackType output;
813
724
        BraseroImageFormat format;
838
749
        /* Find one available output format */
839
750
        format = BRASERO_IMAGE_FORMAT_CDRDAO;
840
751
        output.type = BRASERO_TRACK_TYPE_IMAGE;
841
 
        burner = brasero_burn_session_get_burner (session);
842
752
 
843
753
        for (; format > BRASERO_IMAGE_FORMAT_NONE; format >>= 1) {
844
754
                gboolean supported;
866
776
                        if (caps->type.type != BRASERO_TRACK_TYPE_DISC)
867
777
                                continue;
868
778
 
869
 
                        /* Make sure this is supported by the drive */
870
 
                        if (!brasero_drive_can_write_media (burner, caps->type.subtype.media))
871
 
                                continue;
872
 
 
873
779
                        result = brasero_caps_find_link (caps,
874
 
                                                         use_flags,
 
780
                                                         TRUE,
875
781
                                                         session_flags,
876
782
                                                         caps->type.subtype.media,
877
 
                                                         &output,
 
783
                                                         &input,
878
784
                                                         BRASERO_PLUGIN_IO_ACCEPT_FILE);
879
785
 
880
786
                        BRASERO_BURN_LOG_DISC_TYPE (caps->type.subtype.media,
881
787
                                                    "Tested medium (%s)",
882
788
                                                    result ? "working":"not working");
883
789
 
884
 
                        if (result) {
885
 
                                if (tmp_type) {
886
 
                                        tmp_type->type = BRASERO_TRACK_TYPE_IMAGE;
887
 
                                        tmp_type->subtype.img_format = format;
888
 
                                }
889
 
                                        
 
790
                        if (result)
890
791
                                return BRASERO_BURN_OK;
891
 
                        }
892
792
                }
893
793
        }
894
794
 
896
796
}
897
797
 
898
798
BraseroBurnResult
899
 
brasero_burn_session_get_tmp_image_type_same_src_dest (BraseroBurnSession *session,
900
 
                                                       BraseroTrackType *image_type)
901
 
{
902
 
        BraseroBurnResult result;
903
 
        BraseroBurnCaps *self;
904
 
 
905
 
        self = brasero_burn_caps_get_default ();
906
 
        result = brasero_burn_caps_is_session_supported_same_src_dest (self,
907
 
                                                                       session,
908
 
                                                                       image_type,
909
 
                                                                       TRUE);
910
 
        g_object_unref (self);
911
 
        return result;
912
 
}
913
 
 
914
 
/**
915
 
 * brasero_burn_session_can_burn:
916
 
 * @session: a #BraseroBurnSession
917
 
 * @use_flags: a #gboolean
918
 
 *
919
 
 * Given the various parameters stored in @session, this
920
 
 * function checks whether the data contained in @session
921
 
 * can be burnt to the medium in the #BraseroDrive (set 
922
 
 * through brasero_burn_session_set_burner ()).
923
 
 * If @use_flags is set to TRUE the flags are taken into
924
 
 * account, otherwise they are not.
925
 
 *
926
 
 * Return value: a #BraseroBurnResult.
927
 
 * BRASERO_BURN_OK if it is possible.
928
 
 * BRASERO_BURN_ERR otherwise.
929
 
 **/
930
 
 
931
 
BraseroBurnResult
932
799
brasero_burn_session_can_burn (BraseroBurnSession *session,
933
800
                               gboolean use_flags)
934
801
{
944
811
        if (brasero_burn_session_same_src_dest_drive (session)) {
945
812
                BraseroBurnResult res;
946
813
 
947
 
                res = brasero_burn_caps_is_session_supported_same_src_dest (self, session, NULL, use_flags);
 
814
                res = brasero_burn_caps_is_session_supported_same_src_dest (self, session, use_flags);
948
815
                g_object_unref (self);
949
816
                return res;
950
817
        }
1005
872
        return BRASERO_BURN_OK;
1006
873
}
1007
874
 
1008
 
/**
1009
 
 * brasero_burn_session_get_required_media_type:
1010
 
 * @session: a #BraseroBurnSession
1011
 
 *
1012
 
 * Return the medium types that could be used to burn
1013
 
 * @session.
1014
 
 *
1015
 
 * Return value: a #BraseroMedia
1016
 
 **/
1017
 
 
1018
875
BraseroMedia
1019
876
brasero_burn_session_get_required_media_type (BraseroBurnSession *session)
1020
877
{
1088
945
        return required_media;
1089
946
}
1090
947
 
1091
 
/**
1092
 
 * brasero_burn_session_get_possible_output_formats:
1093
 
 * @session: a #BraseroBurnSession
1094
 
 * @formats: a #BraseroImageFormat
1095
 
 *
1096
 
 * Returns the disc image types that could be set to create
1097
 
 * an image given the current state of @session.
1098
 
 *
1099
 
 * Return value: a #guint. The number of formats available.
1100
 
 **/
1101
 
 
1102
948
guint
1103
949
brasero_burn_session_get_possible_output_formats (BraseroBurnSession *session,
1104
950
                                                  BraseroImageFormat *formats)
1132
978
        return num;
1133
979
}
1134
980
 
1135
 
/**
1136
 
 * brasero_burn_session_get_default_output_format:
1137
 
 * @session: a #BraseroBurnSession
1138
 
 *
1139
 
 * Returns the default disc image type that should be set to create
1140
 
 * an image given the current state of @session.
1141
 
 *
1142
 
 * Return value: a #BraseroImageFormat
1143
 
 **/
1144
 
 
1145
981
BraseroImageFormat
1146
982
brasero_burn_session_get_default_output_format (BraseroBurnSession *session)
1147
983
{
1333
1169
        return retval;
1334
1170
}
1335
1171
 
1336
 
/* FIXME: make this public */
1337
 
gboolean
1338
 
brasero_medium_can_use_sao (BraseroMedium *medium);
1339
 
gboolean
1340
 
brasero_medium_can_use_tao (BraseroMedium *medium);
1341
 
 
1342
 
static void
 
1172
static BraseroBurnFlag
1343
1173
brasero_medium_supported_flags (BraseroMedium *medium,
1344
 
                                BraseroBurnFlag *supported_flags,
1345
 
                                BraseroBurnFlag *compulsory_flags)
 
1174
                                BraseroBurnFlag flags)
1346
1175
{
1347
1176
        BraseroMedia media;
1348
1177
 
1350
1179
 
1351
1180
        /* This is always FALSE */
1352
1181
        if (media & BRASERO_MEDIUM_PLUS)
1353
 
                (*supported_flags) &= ~BRASERO_BURN_FLAG_DUMMY;
 
1182
                flags &= ~BRASERO_BURN_FLAG_DUMMY;
1354
1183
 
1355
1184
        /* Simulation is only possible according to write modes. This mode is
1356
1185
         * mostly used by cdrecord/wodim for CLONE images. */
1357
1186
        else if (media & BRASERO_MEDIUM_DVD) {
1358
1187
                if (!brasero_medium_can_use_dummy_for_sao (medium))
1359
 
                        (*supported_flags) &= ~BRASERO_BURN_FLAG_DUMMY;
 
1188
                        flags &= ~BRASERO_BURN_FLAG_DUMMY;
1360
1189
        }
1361
 
        else if ((*supported_flags) & BRASERO_BURN_FLAG_DAO) {
 
1190
        else if (flags & BRASERO_BURN_FLAG_DAO) {
1362
1191
                if (!brasero_medium_can_use_dummy_for_sao (medium))
1363
 
                        (*supported_flags) &= ~BRASERO_BURN_FLAG_DUMMY;
 
1192
                        flags &= ~BRASERO_BURN_FLAG_DUMMY;
1364
1193
        }
1365
1194
        else if (!brasero_medium_can_use_dummy_for_tao (medium))
1366
 
                (*supported_flags) &= ~BRASERO_BURN_FLAG_DUMMY;
1367
 
 
1368
 
        /* The following is only true if we won't _have_ to blank
1369
 
         * the disc since a CLOSED disc is not able for tao/sao.
1370
 
         * so if BLANK_BEFORE_RIGHT is TRUE then we leave 
1371
 
         * the benefit of the doubt, but flags should be rechecked
1372
 
         * after the drive was blanked. */
1373
 
        if (((*compulsory_flags) & BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE) == 0
1374
 
        &&  !BRASERO_MEDIUM_RANDOM_WRITABLE (media)
1375
 
        &&  !brasero_medium_can_use_tao (medium)) {
1376
 
                (*supported_flags) &= ~BRASERO_BURN_FLAG_MULTI;
1377
 
 
1378
 
                if (brasero_medium_can_use_sao (medium))
1379
 
                        (*compulsory_flags) |= BRASERO_BURN_FLAG_DAO;
1380
 
                else
1381
 
                        (*supported_flags) &= ~BRASERO_BURN_FLAG_DAO;
1382
 
        }
 
1195
                flags &= ~BRASERO_BURN_FLAG_DUMMY;
1383
1196
 
1384
1197
        if (!brasero_medium_can_use_burnfree (medium))
1385
 
                (*supported_flags) &= ~BRASERO_BURN_FLAG_BURNPROOF;
 
1198
                flags &= ~BRASERO_BURN_FLAG_BURNPROOF;
 
1199
 
 
1200
        return flags;
1386
1201
}
1387
1202
 
1388
 
static void
1389
 
brasero_burn_caps_flags_update_for_drive (BraseroBurnSession *session,
1390
 
                                          BraseroBurnFlag *supported_flags,
1391
 
                                          BraseroBurnFlag *compulsory_flags)
 
1203
static BraseroBurnFlag
 
1204
brasero_burn_caps_flags_update_for_drive (BraseroBurnFlag flags,
 
1205
                                          BraseroBurnSession *session)
1392
1206
{
1393
1207
        BraseroDrive *drive;
1394
1208
        BraseroMedium *medium;
1395
1209
 
1396
1210
        drive = brasero_burn_session_get_burner (session);
1397
1211
        if (!drive)
1398
 
                return;
 
1212
                return flags;
1399
1213
 
1400
1214
        medium = brasero_drive_get_medium (drive);
1401
1215
        if (!medium)
1402
 
                return;
 
1216
                return TRUE;
1403
1217
 
1404
 
        brasero_medium_supported_flags (medium,
1405
 
                                        supported_flags,
1406
 
                                        compulsory_flags);
 
1218
        return brasero_medium_supported_flags (medium, flags);
1407
1219
}
1408
1220
 
1409
1221
static BraseroBurnResult
1500
1312
        /* see if we can add BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE. Add it when:
1501
1313
         * - media can be blanked, it has audio or data and we're not merging
1502
1314
         * - media is not formatted and it can be blanked/formatted */
1503
 
        if (brasero_burn_caps_can_blank_real (self, media, session_flags) == BRASERO_BURN_OK)
 
1315
        if (BRASERO_BURN_CAPS_SHOULD_BLANK (media, session_flags)
 
1316
        &&  brasero_burn_caps_can_blank_real (self, media, session_flags) == BRASERO_BURN_OK)
1504
1317
                (*supported_flags) |= BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE;
1505
1318
        else if (session_flags & BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE)
1506
1319
                return BRASERO_BURN_NOT_SUPPORTED;
1507
1320
 
1508
 
        if (((*supported_flags) & BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE) != 0) {
 
1321
        if (((*supported_flags) & BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE)) {
1509
1322
                BraseroBurnFlag blank_compulsory = BRASERO_BURN_FLAG_NONE;
1510
1323
                BraseroBurnFlag blank_supported = BRASERO_BURN_FLAG_NONE;
1511
1324
 
1529
1342
                 * Ex: a CDRW with data appendable can be either appended (then
1530
1343
                 * no DAO possible) or blanked and written (DAO possible). */
1531
1344
 
 
1345
                (*supported_flags) |= BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE;
 
1346
 
1532
1347
                /* result here is the result of the first operation, so if it
1533
1348
                 * failed, BLANK before becomes compulsory. */
1534
1349
                if (result != BRASERO_BURN_OK)
1567
1382
        else if (result != BRASERO_BURN_OK)
1568
1383
                return result;
1569
1384
 
1570
 
        /* These are a special case for DVDRW sequential */
1571
 
        if (BRASERO_MEDIUM_IS (media, BRASERO_MEDIUM_DVDRW)) {
1572
 
                /* That's a way to give priority to MULTI over FAST
1573
 
                 * and leave the possibility to always use MULTI. */
1574
 
                if (session_flags & BRASERO_BURN_FLAG_MULTI)
1575
 
                        (*supported_flags) &= ~BRASERO_BURN_FLAG_FAST_BLANK;
1576
 
                else if ((session_flags & BRASERO_BURN_FLAG_FAST_BLANK)
1577
 
                         &&  (session_flags & BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE)) {
1578
 
                        /* We should be able to handle this case differently but unfortunately
1579
 
                         * there are buggy firmwares that won't report properly the supported
1580
 
                         * mode writes */
1581
 
                        if (!((*supported_flags) & BRASERO_BURN_FLAG_DAO))
1582
 
                                         return BRASERO_BURN_NOT_SUPPORTED;
1583
 
 
1584
 
                        (*compulsory_flags) |= BRASERO_BURN_FLAG_DAO;
1585
 
                }
1586
 
        }
1587
 
 
1588
1385
        if (session_flags & BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE) {
1589
1386
                /* make sure we remove MERGE/APPEND from supported and
1590
1387
                 * compulsory since that's not possible anymore */
1704
1501
        return BRASERO_BURN_OK;
1705
1502
}
1706
1503
 
1707
 
/**
1708
 
 * brasero_burn_session_get_burn_flags:
1709
 
 * @session: a #BraseroBurnSession
1710
 
 * @supported: a #BraseroBurnFlag or NULL
1711
 
 * @compulsory: a #BraseroBurnFlag or NULL
1712
 
 *
1713
 
 * Given the various parameters stored in @session, this function
1714
 
 * stores:
1715
 
 * - the flags that can be used (@supported)
1716
 
 * - the flags that must be used (@compulsory)
1717
 
 * when writing @session to a disc.
1718
 
 *
1719
 
 * Return value: a #BraseroBurnResult.
1720
 
 * BRASERO_BURN_OK if the retrieval was successful.
1721
 
 * BRASERO_BURN_ERR otherwise.
1722
 
 **/
1723
 
 
1724
1504
BraseroBurnResult
1725
1505
brasero_burn_session_get_burn_flags (BraseroBurnSession *session,
1726
1506
                                     BraseroBurnFlag *supported,
1766
1546
 
1767
1547
        /* special case */
1768
1548
        if (brasero_burn_session_same_src_dest_drive (session)) {
1769
 
                BRASERO_BURN_LOG ("Same source and destination");
1770
1549
                result = brasero_burn_caps_get_flags_same_src_dest (self,
1771
1550
                                                                    session,
1772
1551
                                                                    &supported_flags,
1827
1606
        if (result != BRASERO_BURN_OK)
1828
1607
                return result;
1829
1608
 
1830
 
        brasero_burn_caps_flags_update_for_drive (session,
1831
 
                                                  &supported_flags,
1832
 
                                                  &compulsory_flags);
 
1609
        supported_flags = brasero_burn_caps_flags_update_for_drive (supported_flags,
 
1610
                                                                    session);
1833
1611
 
1834
1612
        if (supported)
1835
1613
                *supported = supported_flags;