diff --git a/app/controllers/api/videos.php b/app/controllers/api/videos.php index 5a2f70fe17..b671e04462 100644 --- a/app/controllers/api/videos.php +++ b/app/controllers/api/videos.php @@ -659,10 +659,10 @@ App::get('/v1/videos/:videoId/protocols/:protocolId') 'name' => $value['language'], 'default' => ($key === 0) ? 'YES' : 'NO', 'language' => $value['language'], - 'uri' => $baseUrl . '/renditions/' . $rendition->getId() . '/types/' . $value['id'], + 'uri' => $baseUrl . '/renditions/' . $rendition->getId() . '/streams/' . $value['id'], ]; } elseif ($value['type'] === 'video') { - $uri = $baseUrl . '/renditions/' . $rendition->getId() . '/types/' . $value['id']; + $uri = $baseUrl . '/renditions/' . $rendition->getId() . '/streams/' . $value['id']; } } @@ -696,7 +696,6 @@ App::get('/v1/videos/:videoId/protocols/:protocolId') $attributes = (array)$xml->attributes(); $mpd = $attributes['@attributes'] ?? []; $streamId = 0; - foreach ($xml->Period->AdaptationSet ?? [] as $adaptation) { $representation = []; $representation['id'] = $streamId; diff --git a/app/init.php b/app/init.php index 33f04fea1e..a41be9139a 100644 --- a/app/init.php +++ b/app/init.php @@ -845,6 +845,8 @@ App::setResource('project', function ($dbForConsole, $request, $console) { /** @var Utopia\Database\Document $console */ //$projectId = 'dev'; + + $projectId = $request->getParam('project', $request->getHeader('x-appwrite-project', 'console')); if ($projectId === 'console') { diff --git a/composer.json b/composer.json index 8e96f6fccb..512283f370 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "autoload-dev": { "psr-4": { "Tests\\E2E\\": "tests/e2e", + "Tests\\Unit\\": "tests/unit", "Appwrite\\Tests\\": "tests/extensions" } }, @@ -41,8 +42,8 @@ "ext-zlib": "*", "ext-sockets": "*", "appwrite/php-clamav": "1.1.*", - "appwrite/php-runtimes": "0.10.*", - "utopia-php/framework": "0.20.*", + "appwrite/php-runtimes": "0.11.*", + "utopia-php/framework": "0.21.*", "utopia-php/logger": "0.3.*", "utopia-php/abuse": "0.7.*", "utopia-php/analytics": "0.2.*", diff --git a/tests/e2e/Services/Videos/VideoCustomServerTest.php b/tests/e2e/Services/Videos/VideoCustomServerTest.php index 763922d025..57ce70f7f4 100644 --- a/tests/e2e/Services/Videos/VideoCustomServerTest.php +++ b/tests/e2e/Services/Videos/VideoCustomServerTest.php @@ -487,9 +487,9 @@ class VideoCustomServerTest extends Scope ]); $this->assertEquals(200, $response['headers']['status-code']); preg_match_all('#\b/videos[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $response['body'], $match); - $this->assertEquals(3, count($match[0])); - $subtitleUri = $match[0][0]; - $renditionUri = $match[0][2]; + $this->assertEquals(4, count($match[0])); + $subtitleUri = $match[0][1]; + $renditionUri = $match[0][3]; $response = $this->client->call(Client::METHOD_GET, $renditionUri, [ 'content-type' => 'application/json', @@ -498,7 +498,7 @@ class VideoCustomServerTest extends Scope ]); $this->assertEquals(200, $response['headers']['status-code']); preg_match_all('#\b/videos[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $response['body'], $match); - $this->assertEquals(9, count($match[0])); + $this->assertEquals(12, count($match[0])); $segmentUri = $match[0][0]; $response = $this->client->call(Client::METHOD_GET, $segmentUri, [ @@ -537,8 +537,8 @@ class VideoCustomServerTest extends Scope $xml = simplexml_load_string($response['body']); $this->assertEquals("PT1M32.7S", $xml->attributes()->mediaPresentationDuration); - $this->assertEquals("PT10.0S", $xml->attributes()->maxSegmentDuration); - $this->assertEquals("PT27.0S", $xml->attributes()->minBufferTime); + $this->assertEquals("PT8.0S", $xml->attributes()->maxSegmentDuration); + $this->assertEquals("PT20.5S", $xml->attributes()->minBufferTime); $subsCount = 0; $isVideo = false; $isAudio = false; @@ -557,7 +557,7 @@ class VideoCustomServerTest extends Scope $this->assertEquals("300", $representation['width']); $this->assertEquals("200", $representation['height']); $this->assertEquals("20:17", $representation['sar']); - $this->assertEquals(8, $representation->SegmentList->SegmentURL->count()); + $this->assertEquals(10, $representation->SegmentList->SegmentURL->count()); $videoSegmentBaseUrl = (string)$representation->BaseURL; $videoSegmentInitialization = (string)$representation->SegmentList->Initialization['sourceURL']; $videoSegmentId = (string)$representation->SegmentList->SegmentURL['media']; @@ -585,7 +585,7 @@ class VideoCustomServerTest extends Scope foreach ($adaptation->Representation as $representation) { $this->assertEquals("audio/mp4", $representation['mimeType']); $this->assertEquals("mp4a.40.2", $representation['codecs']); - $this->assertEquals(10, $representation->SegmentList->SegmentURL->count()); + $this->assertEquals(12, $representation->SegmentList->SegmentURL->count()); $audioSegmentBaseUrl = (string)$representation->BaseURL; $audioSegmentInitialization = (string)$representation->SegmentList->Initialization['sourceURL']; $audioSegmentId = (string)$representation->SegmentList->SegmentURL['media']; @@ -723,7 +723,7 @@ class VideoCustomServerTest extends Scope ]); $this->assertEquals(200, $response['headers']['status-code']); preg_match_all('#\b/videos[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $response['body'], $match); - $this->assertEquals(1, count($match[0])); + $this->assertEquals(2, count($match[0])); $renditionUri = $match[0][0]; $response = $this->client->call(Client::METHOD_GET, $renditionUri, [ @@ -733,7 +733,7 @@ class VideoCustomServerTest extends Scope ]); $this->assertEquals(200, $response['headers']['status-code']); preg_match_all('#\b/videos[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $response['body'], $match); - $this->assertEquals(9, count($match[0])); + $this->assertEquals(12, count($match[0])); $segmentUri = $match[0][0]; $response = $this->client->call(Client::METHOD_GET, $segmentUri, [ @@ -755,8 +755,8 @@ class VideoCustomServerTest extends Scope $xml = simplexml_load_string($response['body']); $this->assertEquals("PT1M32.7S", $xml->attributes()->mediaPresentationDuration); - $this->assertEquals("PT10.0S", $xml->attributes()->maxSegmentDuration); - $this->assertEquals("PT27.0S", $xml->attributes()->minBufferTime); + $this->assertEquals("PT8.0S", $xml->attributes()->maxSegmentDuration); + $this->assertEquals("PT20.5S", $xml->attributes()->minBufferTime); $isVideo = false; foreach ($xml->Period->AdaptationSet as $adaptation) { @@ -772,7 +772,7 @@ class VideoCustomServerTest extends Scope $this->assertEquals("300", $representation['width']); $this->assertEquals("200", $representation['height']); $this->assertEquals("20:17", $representation['sar']); - $this->assertEquals(8, $representation->SegmentList->SegmentURL->count()); + $this->assertEquals(10, $representation->SegmentList->SegmentURL->count()); $videoSegmentBaseUrl = (string)$representation->BaseURL; $videoSegmentInitialization = (string)$representation->SegmentList->Initialization['sourceURL']; $videoSegmentId = (string)$representation->SegmentList->SegmentURL['media']; @@ -800,7 +800,7 @@ class VideoCustomServerTest extends Scope foreach ($adaptation->Representation as $representation) { $this->assertEquals("audio/mp4", $representation['mimeType']); $this->assertEquals("mp4a.40.2", $representation['codecs']); - $this->assertEquals(10, $representation->SegmentList->SegmentURL->count()); + $this->assertEquals(12, $representation->SegmentList->SegmentURL->count()); $audioSegmentBaseUrl = (string)$representation->BaseURL; $audioSegmentInitialization = (string)$representation->SegmentList->Initialization['sourceURL']; $audioSegmentId = (string)$representation->SegmentList->SegmentURL['media'];