summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-07-29 04:58:22 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-07-29 04:58:22 +0000
commit258e4fcdf22745ce2b119df63458790461a6fbf0 (patch)
tree779f2a232d11bd2cbd4efca72f450e1af2640320
parentdb47bcb6c018fecae71b8b7120c70d7ef9c7bcf6 (diff)
downloadampache-258e4fcdf22745ce2b119df63458790461a6fbf0.tar.gz
ampache-258e4fcdf22745ce2b119df63458790461a6fbf0.tar.bz2
ampache-258e4fcdf22745ce2b119df63458790461a6fbf0.zip
fixed downsampling, renamed to transcoding default or always are now the options
-rw-r--r--config/ampache.cfg.php.dist6
-rw-r--r--lib/class/song.class.php37
-rw-r--r--lib/class/user.class.php2
-rw-r--r--lib/preferences.php9
-rw-r--r--lib/stream.lib.php17
-rw-r--r--play/index.php2
6 files changed, 31 insertions, 42 deletions
diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist
index 2ead7947..da431703 100644
--- a/config/ampache.cfg.php.dist
+++ b/config/ampache.cfg.php.dist
@@ -464,9 +464,9 @@ transcode_flac_target = mp3
transcode_mp3_target = mp3
; These are the commands that will be run to transcode the file
-trascode_cmd_flac = flac -dc %FILE% | lame -r -b 128 -S - -
-trascode_cmd_m4a = faad -f 2 -w %FILE% | lame -r -b 128 -S - -
-transcode_cmd_mp3 = mp3splt -qnf %FILE% %OFFSET% %EOF% -o - | lame --mp3input -q 3 -b %SAMPLE% -S - -
+trascode_cmd_flac = "flac -dc %FILE% | lame -r -b 128 -S - - "
+trascode_cmd_m4a = "faad -f 2 -w %FILE% | lame -r -b 128 -S - -"
+transcode_cmd_mp3 = "mp3splt -qnf %FILE% %OFFSET% %EOF% -o - | lame --mp3input -q 3 -b %SAMPLE% -S - -"
;######################################################
; these options allow you to configure your rss-feed
diff --git a/lib/class/song.class.php b/lib/class/song.class.php
index 1dd7aa20..9e2e5da2 100644
--- a/lib/class/song.class.php
+++ b/lib/class/song.class.php
@@ -789,20 +789,19 @@ class Song {
} // get_url
- /*!
- @function native_stream
- @discussion returns true if the $song->type streams ok, false if it must be transcoded to stream
- */
- function native_stream() {
+ /**
+ * native_stream
+ * This returns true/false if this can be nativly streamed
+ */
+ public function native_stream() {
if ($this->_transcode) { return false; }
$conf_var = 'transcode_' . $this->type;
$conf_type = 'transcode_' . $this->type . '_target';
-
+
if (Config::get($conf_var)) {
$this->_transcode = true;
- $this->format_type(Config::get($conf_type));
debug_event('auto_transcode','Transcoding to ' . $this->type,'5');
return false;
}
@@ -820,21 +819,19 @@ class Song {
*/
function stream_cmd() {
- $parts = pathinfo($this->file);
+ // Find the target for this transcode
+ $conf_type = 'transcode_' . $this->type . '_target';
+ $this->format_type(Config::get($conf_type));
+ $stream_cmd = 'transcode_cmd_' . $this->type;
+ if (Config::get($stream_cmd)) {
+ return $stream_cmd;
+ }
+ else {
+ debug_event('Downsample','Error: Transcode ' . $stream_cmd . ' for ' . $this->type . ' not found, using downsample','2');
+ }
-
- if (!$this->native_stream()) {
- $stream_cmd = 'stream_cmd_' . $parts['extension'];
- if (conf($stream_cmd)) {
- return $stream_cmd;
- }
- else {
- debug_event('Downsample','Error: Stream command for ' . $parts['extension'] . ' not found, using downsample','2');
- }
- } // end if not native_stream
-
- return 'downsample_cmd';
+ return false;
} // end stream_cmd
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index 5924eec1..5867a4bb 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -397,11 +397,9 @@ class User {
if (empty($data['username'])) {
Error::add('username',_('Error Username Required'));
-echo "WOO";
}
if ($data['password1'] != $data['password2'] AND !empty($data['password1'])) {
-echo "WOO";
Error::add('password',_("Error Passwords don't match"));
}
diff --git a/lib/preferences.php b/lib/preferences.php
index 18b88057..a2dc0afe 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -248,8 +248,7 @@ function create_preference_input($name,$value) {
echo "</select>\n";
break;
case 'play_type':
- if ($value == 'downsample') { $is_down = 'selected="selected"'; }
- elseif ($value == 'localplay') { $is_local = 'selected="selected"'; }
+ if ($value == 'localplay') { $is_local = 'selected="selected"'; }
elseif ($value == 'democratic') { $is_vote = 'selected="selected"'; }
elseif ($value == 'xspf_player') { $is_xspf_player = 'selected="selected"'; }
else { $is_stream = "selected=\"selected\""; }
@@ -347,10 +346,10 @@ function create_preference_input($name,$value) {
echo "</select>\n";
break;
case 'transcode':
+ ${$value} = ' selected="selected"';
echo "<select name=\"$name\">\n";
- echo "\t<option value=\"default\">" . _('Default') . "</option>\n";
- echo "\t<option value=\"acl\">" . _('Follow ACL Rules') . "</option>\n";
- echo "\t<option value=\"always\">" . _('Always') . "</option>\n";
+ echo "\t<option value=\"default\"$default>" . _('Default') . "</option>\n";
+ echo "\t<option value=\"always\"$always>" . _('Always') . "</option>\n";
echo "</select>\n";
break;
default:
diff --git a/lib/stream.lib.php b/lib/stream.lib.php
index 6ec5c3df..9b9b19c1 100644
--- a/lib/stream.lib.php
+++ b/lib/stream.lib.php
@@ -125,20 +125,16 @@ function check_lock_songs($song_id) {
* start_downsample
* This is a rather complext function that starts the downsampling of a song and returns the
* opened file handled
- * @package General
- * @catagory Downsample
- * @param $song The Song Object
*/
function start_downsample($song,$now_playing_id=0,$song_name=0) {
/* Check to see if bitrates are set if so let's go ahead and optomize! */
- $max_bitrate = conf('max_bit_rate');
- $min_bitrate = conf('min_bit_rate');
+ $max_bitrate = Config::get('max_bit_rate');
+ $min_bitrate = Config::get('min_bit_rate');
$time = time();
- $dbh = dbh();
$user_sample_rate = $GLOBALS['user']->prefs['sample_rate'];
$browser = new Browser();
-
+
if (!$song_name) {
$song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type;
}
@@ -149,13 +145,12 @@ function start_downsample($song,$now_playing_id=0,$song_name=0) {
$sql = "SELECT COUNT(*) FROM now_playing, user_preference, preferences " .
"WHERE preferences.name = 'play_type' AND user_preference.preference = preferences.id " .
"AND now_playing.user = user_preference.user AND user_preference.value='downsample'";
- $db_results = mysql_query($sql,$dbh);
- $results = mysql_fetch_row($db_results);
+ $db_results = Dba::query($sql);
+ $results = Dba::fetch_row($db_results);
// Current number of active streams (current is already in now playing)
$active_streams = $results[0];
-
/* If only one user, they'll get all available. Otherwise split up equally. */
$sample_rate = floor($max_bitrate/$active_streams);
@@ -217,7 +212,7 @@ function start_downsample($song,$now_playing_id=0,$song_name=0) {
$song_file = escapeshellarg($song->file);
/* Replace Variables */
- $downsample_command = conf($song->stream_cmd());
+ $downsample_command = Config::get($song->stream_cmd());
$downsample_command = str_replace("%FILE%",$song_file,$downsample_command);
$downsample_command = str_replace("%OFFSET%",$offset,$downsample_command);
$downsample_command = str_replace("%EOF%",$eof,$downsample_command);
diff --git a/play/index.php b/play/index.php
index a02defcb..438db254 100644
--- a/play/index.php
+++ b/play/index.php
@@ -248,7 +248,7 @@ if (Config::get('access_control') AND Config::get('downsample_remote')) {
} // if access_control
// If they are downsampling, or if the song is not a native stream or it's non-local
-if ($GLOBALS['user']->prefs['play_type'] == 'downsample' || !$song->native_stream() || $not_local) {
+if ($GLOBALS['user']->prefs['transcode'] == 'always' || !$song->native_stream() || $not_local) {
debug_event('downsample','Starting Downsample...','5');
$results = start_downsample($song,$lastid,$song_name);
$fp = $results['handle'];