~ubuntu-branches/debian/wheezy/brasero/wheezy

« back to all changes in this revision

Viewing changes to libbrasero-media/scsi-read-disc-structure.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette, Pedro Fragoso, Luca Bruno, Josselin Mouette, Emilio Pozuelo Monfort
  • Date: 2009-06-24 18:59:46 UTC
  • mfrom: (1.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20090624185946-iyxkgf3gjptir5y3
Tags: 2.26.2-1
[ Pedro Fragoso ]
* Add myself to Maintainer field
  - Thanks Ondřej Surý
* New upstream version (Closes: #528945)
  - Split package into brasero, libbrasero-media0 and libbrasero-dev
  - Add Replaces to libbrasero-media0
  - Bump libgtk to 2.14.0
  - Remove libnotify Build-dep
  - Add Build-dep libnautilus-extension-dev (>= 2.22.2)
    and install it.
  - Add Build-dep to libsm-dev
  - Add Build-dep on intltool
* Install omf files to prevent crash on Help
* Move gstreamer0.10-plugins-bad to Suggests, and add
  dvdauthor and vcdimager
* Recommends gvfs (Closes: #491827)
* Pass --disable-scrollkeeper in DEB_CONFIGURE_EXTRA_FLAGS
* debian/patches/007-fix-gnome-doc-utils-path.patch:
  - Removed, not needed anymore
* debian/patches/008-fix-volume-identifier-crash.patch:
  - Removed, merged upstream
* debian/patches/011_nautilus_menu_move.patch:
 - Move CD/DVD Creator Menu to Acessories, taken from Ubuntu

[ Luca Bruno ]
* debian/control.in:
  - Add Build-Depend gtk-doc-tools 1.9.
* debian/patches/006-fix-libdvdcss.patch:
  - Removed as applied upstream.

[ Josselin Mouette ]
* New upstream release.
* Update build-dependencies.
* Move the translations and data to a new brasero-common package.
* Rewrite the descriptions.
* Add -dev depends to the development package.
* Remove inappropriate recommends in the library package.
* Let’s not forget dvd+rw-tools so that we can write DVDs too.
* Rework dependencies accordingly.
* Put the nautilus extension in brasero.
* Conflict against nautilus-cd-burner to avoid having two burning 
  extensions.
* Include clean-la.mk and gnome-version.mk; build-depend on 
  gnome-pkg-tools 0.7.
* Don’t run dh_makeshlibs on brasero and libbrasero-plugins.
* 011_nautilus_menu_move.patch: add NoDisplay=true, this icon is 
  duplicating existing functionality (brasero icon in sound&video 
  menu, and nautilus autorun).
* Update list of copyright holders.

[ Emilio Pozuelo Monfort ]
* debian/copyright: updated.

[ Josselin Mouette ]
* copyright: improve indentation, and point to versioned LGPL.
* 090_relibtoolize.patch: add a relibtoolization patch to avoid the 
  rpath crap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
/*
 
3
 * Libbrasero-media
 
4
 * Copyright (C) Philippe Rouquier 2005-2009 <bonfire-app@wanadoo.fr>
 
5
 *
 
6
 * Libbrasero-media is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * The Libbrasero-media authors hereby grant permission for non-GPL compatible
 
12
 * GStreamer plugins to be used and distributed together with GStreamer
 
13
 * and Libbrasero-media. This permission is above and beyond the permissions granted
 
14
 * by the GPL license by which Libbrasero-media is covered. If you modify this code
 
15
 * you may extend this exception to your version of the code, but you are not
 
16
 * obligated to do so. If you do not wish to do so, delete this exception
 
17
 * statement from your version.
 
18
 * 
 
19
 * Libbrasero-media is distributed in the hope that it will be useful,
 
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
22
 * GNU Library General Public License for more details.
 
23
 * 
 
24
 * You should have received a copy of the GNU General Public License
 
25
 * along with this program; if not, write to:
 
26
 *      The Free Software Foundation, Inc.,
 
27
 *      51 Franklin Street, Fifth Floor
 
28
 *      Boston, MA  02110-1301, USA.
 
29
 */
 
30
 
 
31
#ifdef HAVE_CONFIG_H
 
32
#  include <config.h>
 
33
#endif
 
34
 
 
35
#include <glib.h>
 
36
 
 
37
#include "brasero-media-private.h"
 
38
 
 
39
#include "scsi-error.h"
 
40
#include "scsi-base.h"
 
41
#include "scsi-command.h"
 
42
#include "scsi-opcodes.h"
 
43
#include "scsi-read-disc-structure.h"
 
44
 
 
45
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
 
46
 
 
47
struct _BraseroReadDiscStructureCDB {
 
48
        uchar opcode;
 
49
 
 
50
        uchar media_type                :4;
 
51
        uchar reserved0                 :4;
 
52
 
 
53
        /* for formats 0x83 */
 
54
        uchar address                   [4];
 
55
        uchar layer_num;
 
56
 
 
57
        uchar format;
 
58
 
 
59
        uchar alloc_len                 [2];
 
60
 
 
61
        uchar reserved1                 :6;
 
62
 
 
63
        /* for formats 0x02, 0x06, 0x07, 0x80, 0x82 */
 
64
        uchar agid                      :2;
 
65
 
 
66
        uchar ctl;
 
67
};
 
68
 
 
69
#else
 
70
 
 
71
struct _BraseroReadDiscStructureCDB {
 
72
        uchar opcode;
 
73
 
 
74
        uchar reserved0                 :4;
 
75
        uchar media_type                :4;
 
76
 
 
77
        uchar address                   [4];
 
78
 
 
79
        uchar layer_num;
 
80
        uchar format;
 
81
 
 
82
        uchar alloc_len                 [2];
 
83
 
 
84
        uchar agid                      :2;
 
85
        uchar reserved1                 :6;
 
86
 
 
87
        uchar ctl;
 
88
};
 
89
 
 
90
#endif
 
91
 
 
92
typedef struct _BraseroReadDiscStructureCDB BraseroReadDiscStructureCDB;
 
93
 
 
94
BRASERO_SCSI_COMMAND_DEFINE (BraseroReadDiscStructureCDB,
 
95
                             READ_DISC_STRUCTURE,
 
96
                             BRASERO_SCSI_READ);
 
97
 
 
98
typedef enum {
 
99
BRASERO_MEDIA_DVD_HD_DVD                        = 0x00,
 
100
BRASERO_MEDIA_BD                                = 0x01
 
101
        /* reserved */
 
102
} BraseroScsiMediaType;
 
103
 
 
104
static BraseroScsiResult
 
105
brasero_read_disc_structure (BraseroReadDiscStructureCDB *cdb,
 
106
                             BraseroScsiReadDiscStructureHdr **data,
 
107
                             int *size,
 
108
                             BraseroScsiErrCode *error)
 
109
{
 
110
        BraseroScsiReadDiscStructureHdr *buffer;
 
111
        BraseroScsiReadDiscStructureHdr hdr;
 
112
        BraseroScsiResult res;
 
113
        int request_size;
 
114
 
 
115
        if (!data || !size) {
 
116
                BRASERO_SCSI_SET_ERRCODE (error, BRASERO_SCSI_BAD_ARGUMENT);
 
117
                return BRASERO_SCSI_FAILURE;
 
118
        }
 
119
 
 
120
        BRASERO_SET_16 (cdb->alloc_len, sizeof (hdr));
 
121
 
 
122
        memset (&hdr, 0, sizeof (hdr));
 
123
        res = brasero_scsi_command_issue_sync (cdb, &hdr, sizeof (hdr), error);
 
124
        if (res)
 
125
                return res;
 
126
 
 
127
        request_size = BRASERO_GET_16 (hdr.len) + sizeof (hdr.len);
 
128
        buffer = (BraseroScsiReadDiscStructureHdr *) g_new0 (uchar, request_size);
 
129
 
 
130
        BRASERO_SET_16 (cdb->alloc_len, request_size);
 
131
        res = brasero_scsi_command_issue_sync (cdb, buffer, request_size, error);
 
132
        if (res) {
 
133
                g_free (buffer);
 
134
                return res;
 
135
        }
 
136
 
 
137
        if (request_size < BRASERO_GET_16 (buffer->len) + sizeof (buffer->len)) {
 
138
                BRASERO_SCSI_SET_ERRCODE (error, BRASERO_SCSI_SIZE_MISMATCH);
 
139
                g_free (buffer);
 
140
                return BRASERO_SCSI_FAILURE;
 
141
        }
 
142
 
 
143
        *data = buffer;
 
144
        *size = request_size;
 
145
 
 
146
        return res;
 
147
}
 
148
 
 
149
BraseroScsiResult
 
150
brasero_mmc2_read_generic_structure (BraseroDeviceHandle *handle,
 
151
                                     BraseroScsiGenericFormatType type,
 
152
                                     BraseroScsiReadDiscStructureHdr **data,
 
153
                                     int *size,
 
154
                                     BraseroScsiErrCode *error)
 
155
{
 
156
        BraseroReadDiscStructureCDB *cdb;
 
157
        BraseroScsiResult res;
 
158
 
 
159
        cdb = brasero_scsi_command_new (&info, handle);
 
160
        cdb->format = type;
 
161
 
 
162
        res = brasero_read_disc_structure (cdb, data, size, error);
 
163
        brasero_scsi_command_free (cdb);
 
164
        return res;
 
165
}
 
166
 
 
167
BraseroScsiResult
 
168
brasero_mmc2_read_dvd_structure (BraseroDeviceHandle *handle,
 
169
                                 int address,
 
170
                                 BraseroScsiDVDFormatType type,
 
171
                                 BraseroScsiReadDiscStructureHdr **data,
 
172
                                 int *size,
 
173
                                 BraseroScsiErrCode *error)
 
174
{
 
175
        BraseroReadDiscStructureCDB *cdb;
 
176
        BraseroScsiResult res;
 
177
 
 
178
        cdb = brasero_scsi_command_new (&info, handle);
 
179
        cdb->format = type;
 
180
        cdb->media_type = BRASERO_MEDIA_DVD_HD_DVD;
 
181
        BRASERO_SET_32 (cdb->address, address);
 
182
 
 
183
        res = brasero_read_disc_structure (cdb, data, size, error);
 
184
        brasero_scsi_command_free (cdb);
 
185
        return res;
 
186
}
 
187
 
 
188
BraseroScsiResult
 
189
brasero_mmc5_read_bd_structure (BraseroDeviceHandle *handle,
 
190
                                BraseroScsiBDFormatType type,
 
191
                                BraseroScsiReadDiscStructureHdr **data,
 
192
                                int *size,
 
193
                                BraseroScsiErrCode *error)
 
194
{
 
195
        BraseroReadDiscStructureCDB *cdb;
 
196
        BraseroScsiResult res;
 
197
 
 
198
        cdb = brasero_scsi_command_new (&info, handle);
 
199
        cdb->format = type;
 
200
        cdb->media_type = BRASERO_MEDIA_BD;
 
201
 
 
202
        res = brasero_read_disc_structure (cdb, data, size, error);
 
203
        brasero_scsi_command_free (cdb);
 
204
        return res;
 
205
}