diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-10-10 07:30:15 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-10-10 07:30:15 +0000 |
commit | ff58181d5b4ddd10b34062a0ad2204435e698cae (patch) | |
tree | 60b4654309d0826c81411790efe8448675a038bb /lib/stream.lib.php | |
parent | 32349846fbd66e4ebc44e63d37fbcd8cff5a8a73 (diff) | |
download | ampache-ff58181d5b4ddd10b34062a0ad2204435e698cae.tar.gz ampache-ff58181d5b4ddd10b34062a0ad2204435e698cae.tar.bz2 ampache-ff58181d5b4ddd10b34062a0ad2204435e698cae.zip |
fixed acls, fixed transcoding issues
Diffstat (limited to 'lib/stream.lib.php')
-rw-r--r-- | lib/stream.lib.php | 111 |
1 files changed, 0 insertions, 111 deletions
diff --git a/lib/stream.lib.php b/lib/stream.lib.php index f6554e8b..5d6448c0 100644 --- a/lib/stream.lib.php +++ b/lib/stream.lib.php @@ -135,117 +135,6 @@ function check_lock_songs($song_id) { } // check_lock_songs -/** - * start_downsample - * This is a rather complext function that starts the downsampling of a song and returns the - * opened file handled - */ -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 = Config::get('max_bit_rate'); - $min_bitrate = Config::get('min_bit_rate'); - $time = time(); - $user_sample_rate = $GLOBALS['user']->prefs['sample_rate']; - $browser = new Browser(); - - if (!$song_name) { - $song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type; - } - - if ($max_bitrate > 1 AND $min_bitrate < $max_bitrate) { - $last_seen_time = $time - 1200; //20 min. - - $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 = 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); - - /* If min_bitrate is set, then we'll exit if the bandwidth would need to be split up smaller than the min. */ - if ($min_bitrate > 1 AND ($max_bitrate/$active_streams) < $min_bitrate) { - - /* Log the failure */ - debug_event('downsample',"Error: Max bandwidith already allocated. $active_streams Active Streams",'2'); - - /* Toast the now playing entry, then tell em to try again later */ - delete_now_playing($now_playing_id); - echo "Maximum bandwidth already allocated. Try again later."; - exit(); - - } - else { - $sample_rate = floor($max_bitrate/$active_streams); - } // end else - - // Never go over the users sample rate - if ($sample_rate > $user_sample_rate) { $sample_rate = $user_sample_rate; } - - debug_event('downsample',"Downsampled: $active_streams current active streams, downsampling to $sample_rate",'2'); - - } // end if we've got bitrates - - else { - $sample_rate = $user_sample_rate; - } - - /* Validate the bitrate */ - $sample_rate = validate_bitrate($sample_rate); - - /* Never Upsample a song */ - if (($sample_rate*1000) > $song->bitrate) { - $sample_rate = validate_bitrate($song->bitrate)/1000; - $sample_ratio = '1'; - } - else { - /* Set the Sample Ratio */ - $sample_ratio = $sample_rate/($song->bitrate/1000); - } - - - header("Content-Length: " . intval($sample_ratio*$song->size)); - $browser->downloadHeaders($song_name, $song->mime, false,$sample_ratio*$song->size); - - /* Get Offset */ - $offset = ( $start*$song->time )/( $sample_ratio*$song->size ); - $offsetmm = floor($offset/60); - $offsetss = floor($offset-$offsetmm*60); - $offset = sprintf("%02d.%02d",$offsetmm,$offsetss); - - /* Get EOF */ - $eofmm = floor($song->time/60); - $eofss = floor($song->time-$eofmm*60); - $eof = sprintf("%02d.%02d",$eofmm,$eofss); - - $song_file = escapeshellarg($song->file); - - /* Replace Variables */ - $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); - $downsample_command = str_replace("%SAMPLE%",$sample_rate,$downsample_command); - - // If we are debugging log this event - $message = "Start Downsample: $downsample_command"; - debug_event('downsample',$message,'3'); - - $fp = @popen($downsample_command, 'rb'); - - /* We need more than just the handle here */ - $return_array['handle'] = $fp; - $return_array['size'] = $sample_ratio*$song->size; - - return ($return_array); - -} // start_downsample - /** * validate_bitrate * this function takes a bitrate and returns a valid one |