test_transcode_profiles.js
Go to the documentation of this file.
1 /* vim: set sw=2 : */
2 /*
3  *=BEGIN SONGBIRD GPL
4  *
5  * This file is part of the Songbird web player.
6  *
7  * Copyright(c) 2005-2009 POTI, Inc.
8  * http://www.songbirdnest.com
9  *
10  * This file may be licensed under the terms of of the
11  * GNU General Public License Version 2 (the ``GPL'').
12  *
13  * Software distributed under the License is distributed
14  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
15  * express or implied. See the GPL for the specific language
16  * governing rights and limitations.
17  *
18  * You should have received a copy of the GPL along with this
19  * program. If not, go to http://www.gnu.org/licenses/gpl.html
20  * or write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22  *
23  *=END SONGBIRD GPL
24  */
25 
26 function runTest() {
27 
28  Components.utils.import("resource://app/jsmodules/ArrayConverter.jsm");
29 
30  var conf = Cc["@songbirdnest.com/Songbird/Mediacore/Transcode/Configurator/Device/GStreamer;1"]
31  .createInstance(Ci.sbITranscodingConfigurator);
32  var profiles = ArrayConverter.JSArray(conf.availableProfiles);
33  var testProfile = null;
34  for each (var profile in profiles) {
35  profile.QueryInterface(Ci.sbITranscodeProfile);
36  log(profile.id + " = " + profile.description);
37  if (profile.id == "072b5104-1dd2-11b2-9313-e80ca3194e4e") {
38  // this is the ogg/theora/vorbis test profile
39  testProfile = profile;
40  }
41  }
42 
43  profile = testProfile.QueryInterface(Ci.sbITranscodeEncoderProfile);
44 
45  const K_PRIORITY_MAP = {"-1": 350,
46  "0": 350,
47  "0.25": 1925,
48  "0.5": 3500,
49  "0.75": 4000,
50  "1": 4500,
51  "2": 4500};
52  const K_BITRATE_MAP = {"-1": 32000,
53  "0": 32000,
54  "0.25": 80000,
55  "0.5": 128000,
56  "0.75": 224000,
57  "1": 320000,
58  "2": 320000};
59  const K_BPP_MAP = {"-1": 0.03,
60  "0": 0.03,
61  "0.25": 0.0975,
62  "0.5": 0.1650,
63  "0.75": 0.2325,
64  "1": 0.3,
65  "2": 0.3};
66 
67  for (var i in K_PRIORITY_MAP) {
68  assertEqual(K_PRIORITY_MAP[i], profile.getEncoderProfilePriority(i));
69  }
70  for (var i in K_BITRATE_MAP) {
71  assertEqual(K_BITRATE_MAP[i], profile.getAudioBitrate(i));
72  }
73  for (var i in K_BPP_MAP) {
74  assertEqual(K_BPP_MAP[i].toFixed(5),
75  profile.getVideoBitsPerPixel(i).toFixed(5));
76  }
77 }
const Cc
function log(s)
function assertEqual(aExpected, aActual, aMessage)
return null
Definition: FeedWriter.js:1143
const Ci
_getSelectedPageStyle s i
function runTest()
Advanced DataRemote unit tests.