public static function get_session() { if (!self::$session) { // Generate the session ID. This is slightly wasteful. $data = array(); $data['type'] = 'stream'; // This shouldn't be done here but at backend endpoint side if (isset($_REQUEST['client'])) { $data['agent'] = $_REQUEST['client']; } // Copy session geolocation // Same thing, should be done elsewhere $sid = session_id(); if ($sid) { $location = Session::get_geolocation($sid); if (isset($location['latitude'])) { $data['geo_latitude'] = $location['latitude']; } if (isset($location['longitude'])) { $data['geo_longitude'] = $location['longitude']; } if (isset($location['name'])) { $data['geo_name'] = $location['name']; } } self::$session = Session::create($data); } return self::$session; }
} if (!isset($_REQUEST['segment'])) { if ($media->time) { header('X-Content-Duration: ' . $media->time); } // Stats registering must be done before play. Do not move it. // It can be slow because of scrobbler plugins (lastfm, ...) if ($start > 0) { debug_event('play', 'Content-Range doesn\'t start from 0, stats should already be registered previously; not collecting stats', 5); } else { if (!$share_id) { if ($_SERVER['REQUEST_METHOD'] != 'HEAD') { debug_event('play', 'Registering stream stats for {' . $media->get_stream_name() . '}...', 5); $sessionkey = $sid ?: Stream::get_session(); $agent = Session::agent($sessionkey); $location = Session::get_geolocation($sessionkey); $GLOBALS['user']->update_stats($type, $media->id, $agent, $location, isset($_REQUEST['noscrobble'])); } } } } if ($transcode || $demo_id) { header('Accept-Ranges: none'); } else { header('Accept-Ranges: bytes'); } $mime = $media->mime; if ($transcode && isset($transcoder)) { $mime = $media->type_to_mime($transcoder['format']); // Non-blocking stream doesn't work in Windows (php bug since 2005 and still here in 2015...) // We don't want to wait indefinitly for a potential error so we just ignore it.