summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-12-29 21:32:03 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-12-29 21:32:03 +0000
commitec19be3ef82d41cfae99d555ce3eef7e162d74c9 (patch)
tree310499ac46d6de1a46a7aa3cecbea536299832bf /lib
parentddc3149e63c7a6da9b0feba9ec2663f1e4c96df4 (diff)
downloadampache-ec19be3ef82d41cfae99d555ce3eef7e162d74c9.tar.gz
ampache-ec19be3ef82d41cfae99d555ce3eef7e162d74c9.tar.bz2
ampache-ec19be3ef82d41cfae99d555ce3eef7e162d74c9.zip
fixed auto-transcoding logic, requires a third variable now if not transcoding to mp3
Diffstat (limited to 'lib')
-rw-r--r--lib/class/song.class.php61
-rw-r--r--lib/init.php10
-rw-r--r--lib/stream.lib.php15
3 files changed, 41 insertions, 45 deletions
diff --git a/lib/class/song.class.php b/lib/class/song.class.php
index 06ca5d54..0e11a3fe 100644
--- a/lib/class/song.class.php
+++ b/lib/class/song.class.php
@@ -152,11 +152,17 @@ class Song {
play, used to set mime headers and to trick
players into playing them correctly
*/
- function format_type() {
+ function format_type($override='') {
- preg_match('/\.([A-Za-z0-9]+)$/', $this->file,$results);
+ // If we pass an override for downsampling or whatever then use it
+ if (!empty($override)) {
+ $this->type = $override;
+ }
+ else {
+ preg_match('/\.([A-Za-z0-9]+)$/', $this->file,$results);
+ $this->type = strtolower($results['1']);
+ }
- $this->type = strtolower($results['1']);
switch ($this->type) {
case 'spx':
@@ -654,6 +660,20 @@ class Song {
*/
function format_song() {
+ $this->format();
+
+ return true;
+
+ }
+
+ /**
+ * format
+ * This takes the current song object
+ * and does a ton of formating on it creating f_??? variables on the current
+ * object
+ */
+ function format() {
+
// Format the filename
preg_match("/^.*\/(.*?)$/",$this->file, $short);
$this->f_file = htmlspecialchars($short[1]);
@@ -820,31 +840,18 @@ class Song {
function native_stream() {
if ($this->_transcode) { return false; }
+
+ $conf_var = 'transcode_' . $this->type;
+ $conf_type = 'transcode_' . $this->type . '_target';
+
+ if (conf($conf_var)) {
+ $this->_transcode = true;
+ $this->format_type(conf($conf_type));
+ debug_event('auto_transcode','Transcoding to ' . conf($conf_type),'5');
+ return false;
+ }
- switch ($this->type) {
- //TODO: fill out these cases once we have it working for m4a
- case 'm4a':
- if (conf('transcode_m4a')) { break; }
- return true;
- break;
- case 'flac':
- if (conf('transcode_flac')) { break; }
- return true;
- break;
- case 'mpc':
- if (conf('transcode_mpc')) { break; }
- return true;
- break;
- default:
- return true;
- break;
- } // end switch
-
- /* If we've made it this far then we must be trying to transcode */
- $this->_transcode = true;
- $this->format_type();
-
- return false;
+ return true;
} // end native_stream
diff --git a/lib/init.php b/lib/init.php
index b7fbdac1..5e96e204 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -256,9 +256,13 @@ if (in_array("http",$results['auth_methods'])) {
} // end if http auth
+if ($no_session) {
+ define('NO_SESSION','1');
+}
+
// If we don't want a session
-if (!isset($no_session) AND conf('use_auth')) {
+if (NO_SESSION != '1' AND conf('use_auth')) {
/* Verify Their session */
if (!vauth_check_session()) { logout(); exit; }
@@ -302,10 +306,6 @@ else {
init_preferences();
}
-/* PHP5 Date problem solved.. ya'll GMT now! */
-$timezone = "TZ=" . conf('time_zone');
-putenv($timezone);
-
/* Add in some variables for ajax done here because we need the user */
$ajax_info['ajax_url'] = $results['web_path'] . '/server/ajax.server.php';
$ajax_info['ajax_info'] = '&amp;user_id=' . $user->id . '&amp;sessid=' . session_id();
diff --git a/lib/stream.lib.php b/lib/stream.lib.php
index 8049be8b..cb935aaf 100644
--- a/lib/stream.lib.php
+++ b/lib/stream.lib.php
@@ -122,6 +122,7 @@ function check_lock_songs($song_id) {
$db_results = mysql_query($sql, dbh());
if (mysql_num_rows($db_results)) {
+ debug_event('lock_songs','Song Already Playing, skipping...','5');
return false;
}
@@ -139,18 +140,6 @@ function check_lock_songs($song_id) {
*/
function start_downsample($song,$now_playing_id=0,$song_name=0) {
- /**
- * Extra check, for now hardcode it to mp3 but if
- * we are transcoding we need to fix the mime type
- * and let the user define what file type it's switching
- * to.
- */
- if (!$song->native_stream()) {
- $song->mime = 'audio/mpeg';
- $song_name = $song->f_artist_full . " - " . $song->title . ".mp3";
- }
-
-
/* 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');
@@ -252,7 +241,7 @@ function start_downsample($song,$now_playing_id=0,$song_name=0) {
/* We need more than just the handle here */
$return_array['handle'] = $fp;
- $return_array['size'] = $sample_ration*$song->size;
+ $return_array['size'] = $sample_ratio*$song->size;
return ($return_array);