Skip to content

Commit

Permalink
video: add support for go-vod run
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <radialapps@gmail.com>
  • Loading branch information
pulsejet committed Oct 20, 2023
1 parent b5e324b commit c9317e9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
15 changes: 14 additions & 1 deletion lib/Controller/OtherController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\StreamResponse;
use OCP\IRequest;

class OtherController extends GenericApiController
{
Expand Down Expand Up @@ -169,8 +170,20 @@ public function static(string $name): Http\Response

break;

case 'go-vod':
switch (\OC::$server->get(IRequest::class)->getParam('arch')) {
case 'x86_64':
case 'amd64':
return new StreamResponse(__DIR__.'/../../bin-ext/go-vod-amd64');

case 'aarch64':
case 'arm64':
return new StreamResponse(__DIR__.'/../../bin-ext/go-vod-aarch64');
}

// no break
default:
throw new \Exception('Unknown static file');
throw Exceptions::NotFound("File not found: {$name}");
}

/** @var Http\Response $response */
Expand Down
4 changes: 4 additions & 0 deletions lib/Controller/VideoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,15 @@ private function getUpstreamInternal(string $client, string $path, string $profi
$url .= "?{$params}";
}

// Initialize request
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HEADER, 0);

// Add header for expected go-vod version
curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-Go-Vod-Version: '.BinExt::GOVOD_VER]);

// Catch connection abort here
ignore_user_abort(true);

Expand Down
2 changes: 1 addition & 1 deletion lib/Service/BinExt.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class BinExt
{
public const EXIFTOOL_VER = '12.60';
public const GOVOD_VER = '0.1.16';
public const GOVOD_VER = '0.1.18';
public const NX_VER_MIN = '1.1';

/** Get the path to the temp directory */
Expand Down
19 changes: 19 additions & 0 deletions scripts/get-bin-ext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ binExtVar() {
php -r "require '$SCRIPT_PATH/../lib/Service/BinExt.php'; echo \OCA\Memories\Service\BinExt::$1;"
}

arch() {
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
ARCH="amd64"
elif [ "$ARCH" = "arm64" ]; then
ARCH="aarch64"
fi
echo $ARCH
}

EXIFTOOL_VER=$(binExtVar EXIFTOOL_VER)
GOVOD_VER=$(binExtVar GOVOD_VER)

# Get exiftool prebuilt binaries
rm -rf bin-ext
mkdir -p bin-ext
cd bin-ext
Expand All @@ -22,15 +33,23 @@ wget -q "https://github.com/pulsejet/exiftool-bin/releases/download/$EXIFTOOL_VE
wget -q "https://github.com/pulsejet/exiftool-bin/releases/download/$EXIFTOOL_VER/exiftool-aarch64-glibc"
chmod 755 *

# Get exiftool source
wget -q "https://github.com/exiftool/exiftool/archive/refs/tags/$EXIFTOOL_VER.zip"
unzip -qq "$EXIFTOOL_VER.zip"
mv "exiftool-$EXIFTOOL_VER" exiftool
rm -rf *.zip exiftool/t exiftool/html exiftool/windows_exiftool
chmod 755 exiftool/exiftool

# Get go-vod prebuilt binaries
echo "Getting go-vod $GOVOD_VER"
wget -q "https://github.com/pulsejet/go-vod/releases/download/$GOVOD_VER/go-vod-amd64"
wget -q "https://github.com/pulsejet/go-vod/releases/download/$GOVOD_VER/go-vod-aarch64"
chmod 755 go-vod-*

# Check the version of go-vod is correct internally
if [ "$(./go-vod-$(arch) -version)" != "go-vod $GOVOD_VER" ]; then
echo "[BUG] go-vod binary version mismatch"
exit 1
fi

cd ..

0 comments on commit c9317e9

Please sign in to comment.