25 var
Cc = Components.classes;
26 var
Ci = Components.interfaces;
27 var
Cu = Components.utils;
34 onDialogLoad:
function()
36 this._clearDeviceMenupopup();
39 var menupopup = document.getElementById(
"devices-menupopup");
40 var deviceRegistrar =
Cc[
"@songbirdnest.com/Songbird/DeviceManager;2"]
41 .getService(
Ci.sbIDeviceRegistrar);
42 var devicesArray = deviceRegistrar.devices;
43 for (var
i = 0;
i < devicesArray.length;
i++) {
44 var curDevice = devicesArray.queryElementAt(
i,
Ci.sbIDevice);
46 var deviceNode = document.createElement(
"menuitem");
47 deviceNode.setAttribute(
"label", curDevice.name);
48 deviceNode.setAttribute(
"device_id", curDevice.id);
50 menupopup.appendChild(deviceNode);
54 this._commandHandler =
function() {
55 self._onDeviceSelected();
57 menupopup.addEventListener(
"command",
self._commandHandler,
false);
60 _onDeviceSelected:
function()
63 document.getElementById(
"devices-menulist").selectedItem;
66 var deviceID = selectedItem.getAttribute(
"device_id");
67 if (deviceID == this._curSelectedDeviceId) {
72 var deviceRegistrar =
Cc[
"@songbirdnest.com/Songbird/DeviceManager;2"]
73 .getService(
Ci.sbIDeviceRegistrar);
74 var device = deviceRegistrar.getDevice(Components.ID(deviceID));
81 this._clearDescField();
83 var caps = device.capabilities;
84 var retFormats = caps.getSupportedFunctionTypes({});
87 for (formatIndex in retFormats) {
89 caps.getSupportedContentTypes(retFormats[formatIndex], {});
91 for (var contentCount = 0;
92 contentCount < contentArray.length;
96 caps.getSupportedMimeTypes(contentArray[contentCount], {});
98 for (var formatIndex = 0;
99 formatIndex < formatArray.length;
103 var formats = caps.getFormatTypes(contentArray[contentCount],
104 formatArray[formatIndex],
107 for each (format
in formats) {
109 if (format instanceof
Ci.sbIAudioFormatType) {
110 format.QueryInterface(
Ci.sbIAudioFormatType);
111 this._logAudioFormatType(format, formatArray[formatIndex]);
113 else if (format instanceof
Ci.sbIVideoFormatType) {
114 format.QueryInterface(
Ci.sbIVideoFormatType);
115 this._logVideoFormatType(format, formatArray[formatIndex]);
117 else if (format instanceof
Ci.sbIImageFormatType) {
118 format.QueryInterface(
Ci.sbIImageFormatType);
119 this._logImageFormatType(format, formatArray[formatIndex]);
126 this._logGenericFormatType(contentArray[contentCount],
127 formatArray[formatIndex]);
133 document.getElementById(
"devicecaps-desc").appendChild(
134 document.createTextNode(
this._output));
137 _logGenericFormatType:
function(aContentType, aFormat)
139 var contentType =
"";
140 var sbIDC =
Ci.sbIDeviceCapabilities;
141 switch (aContentType) {
142 case sbIDC.CONTENT_UNKNOWN:
143 contentType =
"UNKNOWN";
146 case sbIDC.CONTENT_FILE:
147 contentType =
"FILE";
150 case sbIDC.CONTENT_FOLDER:
151 contentType =
"FOLDER";
154 case sbIDC.CONTENT_AUDIO:
155 contentType =
"AUDIO";
158 case sbIDC.CONTENT_IMAGE:
159 contentType =
"IMAGE";
162 case sbIDC.CONTENT_VIDEO:
163 contentType =
"VIDEO";
166 case sbIDC.CONTENT_PLAYLIST:
167 contentType =
"PLAYLIST";
170 case sbIDC.CONTENT_ALBUM:
171 contentType =
"ALBUM";
174 case sbIDC.CONTENT_MAX_TYPES:
175 contentType =
"MAX_TYPES";
180 " *** " + contentType +
" FORMAT '" + aFormat +
"' ***\n\n";
183 _logAudioFormatType:
function(aAudioFormat, aFormat)
185 var codec = aAudioFormat.audioCodec;
186 var containerFormat = aAudioFormat.containerFormat;
187 var bitrates = aAudioFormat.supportedBitrates;
188 var sampleRates = aAudioFormat.supportedSampleRates;
189 var channels = aAudioFormat.supportedChannels;
192 " *** AUDIO FORMAT TYPE '" + aFormat +
"' ***\n" +
193 " * codec: " + codec +
"\n" +
194 " * container format: " + containerFormat +
"\n" +
195 " * bitrates: \n" + this._logRange(bitrates,
true) +
196 " * samplerates: \n" + this._logRange(sampleRates,
false) +
197 " * channels: \n" + this._logRange(channels,
true) +
"\n";
200 _logVideoFormatType:
function(aVideoFormat, aFormat)
202 var containerType = aVideoFormat.containerType;
204 var videoStreamType = aVideoFormat.videoStream.type;
205 var videoStreamSizes = aVideoFormat.videoStream.supportedExplicitSizes;
206 var videoStreamWidths = aVideoFormat.videoStream.supportedWidths;
207 var videoStreamHeights = aVideoFormat.videoStream.supportedHeights;
208 var videoStreamBitrates = aVideoFormat.videoStream.supportedBitRates;
209 var videoStreamPars = aVideoFormat.videoStream.supportedPARs;
210 var videoStreamParsIsRange = aVideoFormat.videoStream.doesSupportPARRange;
211 var videoStreamFrameRates = aVideoFormat.videoStream.supportedFrameRates;
212 var videoStreamFrameratesIsRange = aVideoFormat.videoStream.doesSupportFrameRateRange;
214 var audioStreamType = aVideoFormat.audioStream.type;
215 var audioStreamBitrates = aVideoFormat.audioStream.supportedBitRates;
216 var audioStreamSampleRates = aVideoFormat.audioStream.supportedSampleRates;
217 var audioStreamChannels = aVideoFormat.audioStream.supportedChannels;
220 " *** VIDEO FORMAT TYPE '" + aFormat +
"' ***\n" +
221 " * video format container type: " + containerType +
"\n" +
222 " * videostream type: " + videoStreamType +
"\n" +
223 " * videostream supported widths: \n" +
224 this._logRange(videoStreamWidths,
true) +
225 " * videostream supported heights: \n" +
226 this._logRange(videoStreamHeights,
true) +
227 " * videostream bitrates: \n" +
228 this._logRange(videoStreamBitrates,
true) +
229 " * videostream PARs: \n" + this._logFractionRange(videoStreamPars, videoStreamParsIsRange) +
230 " * videostream frame rates: \n" + this._logFractionRange(videoStreamFrameRates, videoStreamFrameratesIsRange) +
231 " * audiostream type: " + audioStreamType +
"\n" +
232 " * audiostream bitrates: \n" +
233 this._logRange(audioStreamBitrates,
true) +
234 " * audiostream samplerates: \n" +
235 this._logRange(audioStreamSampleRates,
false) +
236 " * audiostream channels: \n" +
237 this._logRange(audioStreamChannels,
true) +
"\n";
240 _logImageFormatType:
function(aImageFormat, aFormat)
242 var imgFormat = aImageFormat.imageFormat;
243 var widths = aImageFormat.supportedWidths;
244 var heights = aImageFormat.supportedHeights;
245 var sizes = aImageFormat.supportedExplicitSizes;
248 " *** IMAGE FORMAT TYPE '" + aFormat +
"' ***\n" +
249 " * image format: " + imgFormat +
"\n" +
250 " * image widths: \n" + this._logRange(widths,
true) +
251 " * image heights: \n" + this._logRange(heights,
true) +
252 " * image supported sizes: \n" + this._logSizesArray(sizes) +
"\n";
255 _fractionToString:
function(aFrac)
257 return "" + aFrac.numerator +
"/" + aFrac.denominator;
260 _logFractionRange:
function(aRange, aIsRange)
265 if (aIsRange && aRange.length == 2) {
266 output +=
" - min: " + this._fractionToString(aRange.queryElementAt(
267 0,
Ci.sbIDevCapFraction)) +
"\n" +
268 " - max: " + this._fractionToString(aRange.queryElementAt(
269 1,
Ci.sbIDevCapFraction)) +
"\n";
272 for (var
i = 0;
i < aRange.length;
i++) {
273 output +=
" - " + this._fractionToString(aRange.queryElementAt(
274 i,
Ci.sbIDevCapFraction)) +
"\n";
281 _logRange:
function(aRange, aIsMinMax)
287 output +=
" - min: " + aRange.min +
"\n" +
288 " - max: " + aRange.max +
"\n" +
289 " - step: " + aRange.step +
"\n";
292 for (var
i = 0;
i < aRange.valueCount;
i++) {
293 output +=
" - " + aRange.GetValue(
i) +
"\n";
301 _logSizesArray:
function(aSizesArray)
306 for (var
i = 0;
i < aSizesArray.length;
i++) {
307 var
imageSize = aSizesArray.queryElementAt(
i,
Ci.sbIImageSize);
308 output +=
" - " + imageSize.width +
309 " x " + imageSize.height +
"\n";
316 _logArray:
function(aArray)
321 for (var
i = 0;
i < aArray.length;
i++) {
322 output +=
" - " + aArray[
i] +
"\n";
329 _clearDeviceMenupopup:
function()
331 var menupopup = document.getElementById(
"devices-menupopup");
332 while (menupopup.firstChild) {
333 menupopup.removeChild(menupopup.firstChild);
337 _clearDescField:
function()
339 var desc = document.getElementById(
"devicecaps-desc");
340 while (desc.firstChild) {
341 desc.removeChild(desc.firstChild);
_getSelectedPageStyle s i