Commit 404d6428 authored by Meg Ford's avatar Meg Ford

change code according to review

parent 5d7a9450
......@@ -34,8 +34,9 @@ const Preferences = imports.preferences;
const containerProfileMap = {
OGG: "application/ogg",
MP3: "application/x-id3",
MP4: "video/quicktime,variant=(string)iso"
ID3: "application/x-id3",
MP4: "video/quicktime,variant=(string)iso",
NONE: "none"
};
const audioCodecMap = {
......@@ -43,7 +44,7 @@ const audioCodecMap = {
MP3: "audio/mpeg,mpegversion=(int)1,layer=(int)3",
MP4: "audio/mpeg,mpegversion=(int)4",
OPUS: "audio/x-opus",
OGG_VORBIS: "audio/x-vorbis"
VORBIS: "audio/x-vorbis"
};
const comboBoxMap = {
......@@ -57,7 +58,7 @@ const comboBoxMap = {
const AudioProfile = new Lang.Class({
Name: 'AudioProfile',
assignProfile: function(profileName){
profile: function(profileName){
if (profileName)
this._profileName = profileName;
else
......@@ -67,19 +68,19 @@ const AudioProfile = new Lang.Class({
switch(this._profileName) {
case comboBoxMap.OGG_VORBIS:
this._values.push({ container: containerProfileMap.OGG, audio: audioCodecMap.OGG_VORBIS });
this._values.push({ container: containerProfileMap.OGG, audio: audioCodecMap.VORBIS });
break;
case comboBoxMap.OPUS:
this._values.push({ container: containerProfileMap.OGG, audio: audioCodecMap.OPUS });
break;
case comboBoxMap.FLAC:
this._values.push({ container: containerProfileMap.OGG, audio: audioCodecMap.FLAC });
this._values.push({ audio: audioCodecMap.FLAC });
break;
case comboBoxMap.MP3:
this._values.push({ container: containerProfileMap.MP3, audio: audioCodecMap.MP3 });
this._values.push({ container: containerProfileMap.ID3, audio: audioCodecMap.MP3 });
break;
case comboBoxMap.MP4:
this._values.push({ container: containerProfileMap.AAC, audio: audioCodecMap.MP4 });
this._values.push({ container: containerProfileMap.MP4, audio: audioCodecMap.MP4 });
break;
default:
break;
......@@ -88,20 +89,21 @@ const AudioProfile = new Lang.Class({
mediaProfile: function(){
let idx = 0;
let audioCaps;
this._containerProfile = null;
if (this._values[idx].container) {
log(this._values[idx].container);
log(this._values[idx].audio);
let caps = Gst.Caps.from_string(this._values[idx].container);
this._containerProfile = GstPbutils.EncodingContainerProfile.new("record", null, caps, null);
this._audioCaps = Gst.Caps.from_string(this._values[idx].audio);
this.encodingProfile = GstPbutils.EncodingAudioProfile.new(this._audioCaps, null, null, 1);
audioCaps = Gst.Caps.from_string(this._values[idx].audio);
this.encodingProfile = GstPbutils.EncodingAudioProfile.new(audioCaps, null, null, 1);
this._containerProfile.add_profile(this.encodingProfile);
log(this._containerProfile);
return this._containerProfile;
} else if (!this._values[idx].container && this._values[idx].audio) {
this._audioCaps = Gst.Caps.from_string(this._values[idx].audio);
this.encodingProfile = GstPbutils.EncodingAudioProfile.new(this._audioCaps, null, null, 1);
audioCaps = Gst.Caps.from_string(this._values[idx].audio);
this.encodingProfile = GstPbutils.EncodingAudioProfile.new(audioCaps, null, null, 1);
log(this.encodingProfile);
return this.encodingProfile;
} else {
......@@ -111,15 +113,17 @@ const AudioProfile = new Lang.Class({
fileExtensionReturner: function() {
let idx = 0;
let suffixName;
if (this._values[idx].audio) {
this.suffixName = this.encodingProfile.get_file_extension();
if (this._containerProfile != null)
suffixName = this._containerProfile.get_file_extension();
if (this.suffixName == null)
this.suffixName = this._containerProfile.get_file_extension();
if (suffixName == null)
suffixName = this.encodingProfile.get_file_extension();
}
this.audioSuffix = ("." + this.suffixName);
this.audioSuffix = ("." + suffixName);
return this.audioSuffix;
}
});
......@@ -227,7 +227,7 @@ const Listview = new Lang.Class({
dateTimeCreatedString = dateTimeTag.to_g_date_time();
if (dateTimeCreatedString) {
this.file.dateCreated = dateTimeCreatedString.format(_("%Y-%m-%d %H:%M:%S"));
// log("dateCreated" + this.file.dateCreated);
log("dateCreated" + this.file.dateCreated);
} else if (this.dateCreatedString) {
this.file.dateCreated = this.dateCreatedString;
}
......@@ -310,11 +310,11 @@ const Listview = new Lang.Class({
//log(this.file.fileName);
if (containerCaps.is_subset(Gst.Caps.from_string(AudioProfile.containerProfileMap.OGG))) {
if (audioCaps.is_subset(Gst.Caps.from_string(AudioProfile.audioCodecMap.OGG_VORBIS)))
if (audioCaps.is_subset(Gst.Caps.from_string(AudioProfile.audioCodecMap.VORBIS)))
this.file.mediaType = mediaTypeMap.OGG_VORBIS;
else if (audioCaps.is_subset(Gst.Caps.from_string(AudioProfile.audioCodecMap.OPUS)))
this.file.mediaType = mediaTypeMap.OPUS;
} else if (containerCaps.is_subset(Gst.Caps.from_string(AudioProfile.containerProfileMap.MP3))) {
} else if (containerCaps.is_subset(Gst.Caps.from_string(AudioProfile.containerProfileMap.ID3))) {
if (audioCaps.is_subset(Gst.Caps.from_string(AudioProfile.audioCodecMap.MP3)))
this.file.mediaType = mediaTypeMap.MP3;
} else if (containerCaps.is_subset(Gst.Caps.from_string(AudioProfile.containerProfileMap.MP4))) {
......@@ -322,22 +322,10 @@ const Listview = new Lang.Class({
this.file.mediaType = mediaTypeMap.MP4;
} else if (audioCaps.is_subset(Gst.Caps.from_string(AudioProfile.audioCodecMap.FLAC))) {
this.file.mediaType = mediaTypeMap.FLAC;
} else if (containerCaps) { // !GstPbutils.DiscovererResult.OK should filter these out already
let notKnownContainerCaps = GstPbutils.pb_utils_get_codec_description(containerCaps);
if (notKnownContainerCaps) {
this.file.mediaType = notKnownContainerCaps;
} else if (notKnownContainerCaps == null) {
this.file.mediaType = ""; // provide the line with an empty string as placeholder if we have no info about the caps
}
} else if (containerCaps) {
allFilesInfo.splice(this.idx, 1); // Remove the file from the array if we don't recognize it
} else {
let notKnownAudioCaps = GstPbutils.pb_utils_get_codec_description(audioCaps);
if (notKnownAudioCaps) {
this.file.mediaType = notKnownAudioCaps;
} else if (notKnownAudioCaps == null) {
this.file.mediaType = ""; // provide the line with an empty string as placeholder if we have no info about the caps
}
allFilesInfo.splice(this.idx, 1);// Remove the file from the array if we don't recognize it
}
},
......
// -*- Mode: js; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*-
//
// Copyright (c) 2013 Giovanni Campagna <scampa.giovanni@gmail.com>
// Copyright (c) 2013 Meg Ford <megford@gnome.org>
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
......
......@@ -431,7 +431,7 @@ const MainView = new Lang.Class({
margin_top: 5,
name: "PlayDurationLabel" });
this.fileDuration = this._formatTime(this._files[i].duration/Gst.SECOND);
log(this.fileDuration + "FILEDURATION");
log(this.fileDuration + "FILE DURATION");
log(this._files[i].duration);
this.playDurationLabel.label = this.fileDuration;
this._playLabelBox.pack_start(this.playDurationLabel, false, true, 0);
......@@ -762,7 +762,7 @@ const RecordButton = new Lang.Class({
if (activeProfile == null)
activeProfile = 0;
audioProfile.assignProfile(activeProfile);
audioProfile.profile(activeProfile);
view._record.startRecording(activeProfile);
wave = new Waveform.WaveForm(view.recordGrid);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment