├── .DS_Store ├── README.md ├── architecture.png ├── backend ├── .env.example ├── .gitignore ├── Dockerfile ├── db │ ├── base.py │ ├── db.py │ ├── middleware │ │ └── auth_middleware.py │ ├── models │ │ ├── user.py │ │ └── video.py │ └── redis_db.py ├── docker-compose.yml ├── helper │ └── auth_helper.py ├── main.py ├── pydantic_models │ ├── auth_models.py │ └── upload_models.py ├── requirements.txt ├── routes │ ├── auth.py │ ├── upload.py │ └── video.py └── secret_keys.py ├── consumer ├── .env.example ├── main.py ├── requirements.txt └── secret_keys.py ├── flutter_client ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle.kts │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── flutter_client │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle.kts │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle.kts ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h │ └── RunnerTests │ │ └── RunnerTests.swift ├── lib │ ├── cubits │ │ ├── auth │ │ │ ├── auth_cubit.dart │ │ │ └── auth_state.dart │ │ └── upload_video │ │ │ ├── upload_video_cubit.dart │ │ │ └── upload_video_state.dart │ ├── main.dart │ ├── pages │ │ ├── auth │ │ │ ├── confirm_signup_page.dart │ │ │ ├── login_page.dart │ │ │ └── signup_page.dart │ │ └── home │ │ │ ├── home_page.dart │ │ │ ├── upload_page.dart │ │ │ └── video_player_page.dart │ ├── services │ │ ├── auth_service.dart │ │ ├── upload_video_service.dart │ │ └── video_service.dart │ └── utils │ │ └── utils.dart ├── linux │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ │ ├── CMakeLists.txt │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ └── generated_plugins.cmake │ └── runner │ │ ├── CMakeLists.txt │ │ ├── main.cc │ │ ├── my_application.cc │ │ └── my_application.h ├── macos │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── app_icon_1024.png │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_512.png │ │ │ │ └── app_icon_64.png │ │ ├── Base.lproj │ │ │ └── MainMenu.xib │ │ ├── Configs │ │ │ ├── AppInfo.xcconfig │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ └── Warnings.xcconfig │ │ ├── DebugProfile.entitlements │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements │ └── RunnerTests │ │ └── RunnerTests.swift ├── pubspec.lock ├── pubspec.yaml ├── test │ └── widget_test.dart ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ └── manifest.json └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h └── transcoder ├── .env.example ├── Dockerfile ├── main.py ├── requirements.txt └── secret_keys.py /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Video streaming app similar to YT 2 | 3 | Technologies used: AWS, FastAPI, Redis, Docker, Flutter, PostgreSQL, Bloc 4 | -------------------------------------------------------------------------------- /architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/architecture.png -------------------------------------------------------------------------------- /backend/.env.example: -------------------------------------------------------------------------------- 1 | COGNITO_CLIENT_ID= 2 | COGNITO_CLIENT_SECRET= 3 | REGION_NAME= 4 | POSTGRES_DB_URL= 5 | AWS_RAW_VIDEOS_BUCKET= 6 | AWS_ACCESS_KEY_ID= 7 | AWS_SECRET_ACCESS_KEY= 8 | AWS_VIDEO_THUMBNAIL_BUCKET= 9 | -------------------------------------------------------------------------------- /backend/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | __pycache__ -------------------------------------------------------------------------------- /backend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.11-slim 2 | 3 | WORKDIR /app 4 | 5 | COPY requirements.txt . 6 | 7 | RUN pip install --no-cache-dir -r requirements.txt 8 | 9 | COPY . . 10 | 11 | EXPOSE 8000 12 | 13 | CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"] -------------------------------------------------------------------------------- /backend/db/base.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy.ext.declarative import declarative_base 2 | 3 | Base = declarative_base() 4 | -------------------------------------------------------------------------------- /backend/db/db.py: -------------------------------------------------------------------------------- 1 | from secret_keys import SecretKeys 2 | from sqlalchemy import create_engine 3 | from sqlalchemy.orm import sessionmaker 4 | 5 | secret_keys = SecretKeys() 6 | 7 | engine = create_engine(secret_keys.POSTGRES_DB_URL) 8 | SessionLocal = sessionmaker( 9 | autocommit=False, 10 | autoflush=False, 11 | bind=engine, 12 | ) 13 | 14 | 15 | def get_db(): 16 | db = SessionLocal() 17 | 18 | try: 19 | yield db 20 | finally: 21 | db.close() 22 | -------------------------------------------------------------------------------- /backend/db/middleware/auth_middleware.py: -------------------------------------------------------------------------------- 1 | from fastapi import Cookie, HTTPException 2 | import boto3 3 | from secret_keys import SecretKeys 4 | 5 | cognito_client = boto3.client( 6 | "cognito-idp", 7 | region_name=SecretKeys().REGION_NAME, 8 | ) 9 | 10 | 11 | def _get_user_from_cognito(access_token: str): 12 | try: 13 | user_res = cognito_client.get_user(AccessToken=access_token) 14 | 15 | return { 16 | attr["Name"]: attr["Value"] for attr in user_res.get("UserAttributes", []) 17 | } 18 | except Exception as e: 19 | raise HTTPException(500, "Error fetching user") 20 | 21 | 22 | def get_current_user(access_token: str = Cookie(None)): 23 | if not access_token: 24 | raise HTTPException(401, "User not logged in!") 25 | print(access_token) 26 | return _get_user_from_cognito(access_token) 27 | -------------------------------------------------------------------------------- /backend/db/models/user.py: -------------------------------------------------------------------------------- 1 | from db.base import Base 2 | from sqlalchemy import Column, TEXT, Integer 3 | 4 | 5 | class User(Base): 6 | __tablename__ = "users" 7 | 8 | id = Column(Integer, primary_key=True, index=True) 9 | name = Column(TEXT, nullable=False) 10 | email = Column(TEXT, unique=True, index=True, nullable=False) 11 | cognito_sub = Column(TEXT, unique=True, nullable=False, index=True) 12 | -------------------------------------------------------------------------------- /backend/db/models/video.py: -------------------------------------------------------------------------------- 1 | from db.base import Base 2 | from sqlalchemy import Column, TEXT, Integer, ForeignKey, Enum 3 | import enum 4 | 5 | 6 | class VisibilityStatus(enum.Enum): 7 | PRIVATE = "PRIVATE" 8 | PUBLIC = "PUBLIC" 9 | UNLISTED = "UNLISTED" 10 | 11 | 12 | class ProcessingStatus(enum.Enum): 13 | COMPLETED = "COMPLETED" 14 | FAILED = "FAILED" 15 | IN_PROGRESS = "IN_PROGRESS" 16 | 17 | 18 | class Video(Base): 19 | __tablename__ = "videos" 20 | 21 | id = Column(TEXT, primary_key=True) 22 | title = Column(TEXT) 23 | description = Column(TEXT) 24 | user_id = Column(TEXT, ForeignKey("users.cognito_sub")) 25 | video_s3_key = Column(TEXT) 26 | visibility = Column( 27 | Enum(VisibilityStatus), 28 | nullable=False, 29 | default=VisibilityStatus.PRIVATE, 30 | ) 31 | is_processing = Column( 32 | Enum(ProcessingStatus), 33 | nullable=False, 34 | default=ProcessingStatus.IN_PROGRESS, 35 | ) 36 | 37 | def to_dict(self): 38 | result = {} 39 | for c in self.__table__.columns: 40 | value = getattr(self, c.name) 41 | if isinstance(value, enum.Enum): 42 | value = value.value 43 | result[c.name] = value 44 | return result 45 | -------------------------------------------------------------------------------- /backend/db/redis_db.py: -------------------------------------------------------------------------------- 1 | import redis 2 | 3 | redis_client = redis.Redis(host="redis", port=6379) 4 | -------------------------------------------------------------------------------- /backend/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | fastapi: 3 | build: 4 | context: . 5 | dockerfile: Dockerfile 6 | container_name: fastapi_container 7 | ports: 8 | - "8000:8000" 9 | image: fastapi_app 10 | environment: 11 | - DATABASE_URL=postgresql://postgres:test123@db:5432/mydatabase 12 | volumes: 13 | - ./:/app 14 | db: 15 | image: postgres:15 16 | container_name: postgres_db 17 | ports: 18 | - "5432:5432" 19 | environment: 20 | POSTGRES_DB: mydatabase 21 | POSTGRES_USER: postgres 22 | POSTGRES_PASSWORD: test123 23 | volumes: 24 | - postgres_data:/var/lib/postgresql/data 25 | 26 | redis: 27 | image: redis:7.4.2 28 | container_name: redis 29 | ports: 30 | - "6379:6379" 31 | volumes: 32 | - redis_data:/data 33 | 34 | volumes: 35 | postgres_data: 36 | redis_data: -------------------------------------------------------------------------------- /backend/helper/auth_helper.py: -------------------------------------------------------------------------------- 1 | import base64 2 | import hashlib 3 | import hmac 4 | 5 | 6 | def get_secret_hash(username: str, client_id: str, client_secret: str): 7 | message = username + client_id 8 | 9 | digest = hmac.new( 10 | client_secret.encode("utf-8"), 11 | msg=message.encode("utf-8"), 12 | digestmod=hashlib.sha256, 13 | ).digest() 14 | 15 | return base64.b64encode(digest).decode() 16 | -------------------------------------------------------------------------------- /backend/main.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.middleware.cors import CORSMiddleware 3 | from db.base import Base 4 | from routes import auth, upload, video 5 | from db.db import engine 6 | 7 | app = FastAPI() 8 | 9 | origins = ["http://localhost", "http://localhost:3000"] 10 | 11 | app.add_middleware( 12 | CORSMiddleware, 13 | allow_origins=origins, 14 | allow_credentials=True, 15 | allow_methods=["*"], 16 | allow_headers=["*"], 17 | ) 18 | 19 | app.include_router(auth.router, prefix="/auth") 20 | app.include_router(upload.router, prefix="/upload/video") 21 | app.include_router(video.router, prefix="/videos") 22 | 23 | 24 | @app.get("/") 25 | def root(): 26 | return "Hello, World!!!" 27 | 28 | 29 | Base.metadata.create_all(engine) 30 | -------------------------------------------------------------------------------- /backend/pydantic_models/auth_models.py: -------------------------------------------------------------------------------- 1 | from pydantic import BaseModel 2 | 3 | 4 | class SignupRequest(BaseModel): 5 | name: str 6 | email: str 7 | password: str 8 | 9 | 10 | class LoginRequest(BaseModel): 11 | email: str 12 | password: str 13 | 14 | 15 | class ConfirmSignupRequest(BaseModel): 16 | email: str 17 | otp: str 18 | -------------------------------------------------------------------------------- /backend/pydantic_models/upload_models.py: -------------------------------------------------------------------------------- 1 | from pydantic import BaseModel 2 | 3 | 4 | class UploadMetadata(BaseModel): 5 | title: str 6 | description: str 7 | video_id: str 8 | video_s3_key: str 9 | visibility: str 10 | -------------------------------------------------------------------------------- /backend/requirements.txt: -------------------------------------------------------------------------------- 1 | fastapi 2 | uvicorn 3 | boto3 4 | pydantic-settings 5 | python-dotenv 6 | sqlalchemy 7 | psycopg2-binary 8 | redis -------------------------------------------------------------------------------- /backend/routes/auth.py: -------------------------------------------------------------------------------- 1 | from fastapi import APIRouter, Cookie, Depends, HTTPException, Response 2 | import boto3 3 | from db.db import get_db 4 | from db.middleware.auth_middleware import get_current_user 5 | from db.models.user import User 6 | from helper.auth_helper import get_secret_hash 7 | from pydantic_models.auth_models import ( 8 | ConfirmSignupRequest, 9 | LoginRequest, 10 | SignupRequest, 11 | ) 12 | from secret_keys import SecretKeys 13 | from sqlalchemy.orm import Session 14 | 15 | router = APIRouter() 16 | secret_keys = SecretKeys() 17 | 18 | COGNITO_CLIENT_ID = secret_keys.COGNITO_CLIENT_ID 19 | COGNITO_CLIENT_SECRET = secret_keys.COGNITO_CLIENT_SECRET 20 | 21 | cognito_client = boto3.client( 22 | "cognito-idp", 23 | region_name=secret_keys.REGION_NAME, 24 | ) 25 | 26 | 27 | @router.post("/signup") 28 | def signup_user( 29 | data: SignupRequest, 30 | db: Session = Depends(get_db), 31 | ): 32 | try: 33 | secret_hash = get_secret_hash( 34 | data.email, 35 | COGNITO_CLIENT_ID, 36 | COGNITO_CLIENT_SECRET, 37 | ) 38 | 39 | cognito_response = cognito_client.sign_up( 40 | ClientId=COGNITO_CLIENT_ID, 41 | Username=data.email, 42 | Password=data.password, 43 | SecretHash=secret_hash, 44 | UserAttributes=[ 45 | {"Name": "email", "Value": data.email}, 46 | {"Name": "name", "Value": data.name}, 47 | ], 48 | ) 49 | 50 | cognito_sub = cognito_response.get("UserSub") 51 | 52 | if not cognito_sub: 53 | raise HTTPException(400, "Cognito did not return a valid user sub") 54 | 55 | new_user = User( 56 | name=data.name, 57 | email=data.email, 58 | cognito_sub=cognito_sub, 59 | ) 60 | db.add(new_user) 61 | db.commit() 62 | db.refresh(new_user) 63 | 64 | return {"message": "Signup successful. Please verify your email if required."} 65 | except Exception as e: 66 | raise HTTPException(400, f"Cognito sugnup exception: {e}") 67 | 68 | 69 | @router.post("/login") 70 | def login_user(data: LoginRequest, response: Response): 71 | try: 72 | secret_hash = get_secret_hash( 73 | data.email, 74 | COGNITO_CLIENT_ID, 75 | COGNITO_CLIENT_SECRET, 76 | ) 77 | 78 | cognito_response = cognito_client.initiate_auth( 79 | ClientId=COGNITO_CLIENT_ID, 80 | AuthFlow="USER_PASSWORD_AUTH", 81 | AuthParameters={ 82 | "USERNAME": data.email, 83 | "PASSWORD": data.password, 84 | "SECRET_HASH": secret_hash, 85 | }, 86 | ) 87 | 88 | auth_result = cognito_response.get("AuthenticationResult") 89 | 90 | if not auth_result: 91 | raise HTTPException(400, "Incorrect cognito response") 92 | 93 | access_token = auth_result.get("AccessToken") 94 | refresh_token = auth_result.get("RefreshToken") 95 | 96 | response.set_cookie( 97 | key="access_token", 98 | value=access_token, 99 | httponly=True, 100 | secure=True, 101 | ) 102 | response.set_cookie( 103 | key="refresh_token", 104 | value=refresh_token, 105 | httponly=True, 106 | secure=True, 107 | ) 108 | 109 | return {"message": "User logged in successfully!"} 110 | except Exception as e: 111 | raise HTTPException(400, f"Cognito sugnup exception: {e}") 112 | 113 | 114 | @router.post("/confirm-signup") 115 | def confirm_signup(data: ConfirmSignupRequest): 116 | try: 117 | secret_hash = get_secret_hash( 118 | data.email, 119 | COGNITO_CLIENT_ID, 120 | COGNITO_CLIENT_SECRET, 121 | ) 122 | 123 | cognito_response = cognito_client.confirm_sign_up( 124 | ClientId=COGNITO_CLIENT_ID, 125 | Username=data.email, 126 | ConfirmationCode=data.otp, 127 | SecretHash=secret_hash, 128 | ) 129 | 130 | return {"message": "User confirmed successfully!"} 131 | except Exception as e: 132 | raise HTTPException(400, f"Cognito sugnup exception: {e}") 133 | 134 | 135 | @router.post("/refresh") 136 | def refresh_token( 137 | refresh_token: str = Cookie(None), 138 | user_cognito_sub: str = Cookie(None), 139 | response: Response = None, 140 | ): 141 | try: 142 | if not refresh_token or not user_cognito_sub: 143 | raise HTTPException(400, "cookies cannot be null!") 144 | secret_hash = get_secret_hash( 145 | user_cognito_sub, 146 | COGNITO_CLIENT_ID, 147 | COGNITO_CLIENT_SECRET, 148 | ) 149 | 150 | cognito_response = cognito_client.initiate_auth( 151 | ClientId=COGNITO_CLIENT_ID, 152 | AuthFlow="REFRESH_TOKEN_AUTH", 153 | AuthParameters={ 154 | "REFRESH_TOKEN": refresh_token, 155 | "SECRET_HASH": secret_hash, 156 | }, 157 | ) 158 | auth_result = cognito_response.get("AuthenticationResult") 159 | 160 | if not auth_result: 161 | raise HTTPException(400, "Incorrect cognito response") 162 | 163 | access_token = auth_result.get("AccessToken") 164 | 165 | response.set_cookie( 166 | key="access_token", 167 | value=access_token, 168 | httponly=True, 169 | secure=True, 170 | ) 171 | 172 | return {"message": "Access token refreshed!"} 173 | except Exception as e: 174 | raise HTTPException(400, f"Cognito sugnup exception: {e}") 175 | 176 | 177 | @router.get("/me") 178 | def protected_route(user=Depends(get_current_user)): 179 | return {"message": "You are authenticated!", "user": user} 180 | -------------------------------------------------------------------------------- /backend/routes/upload.py: -------------------------------------------------------------------------------- 1 | import boto3 2 | from fastapi import APIRouter, Depends, HTTPException 3 | from db.db import get_db 4 | from db.models.video import Video 5 | from pydantic_models.upload_models import UploadMetadata 6 | from sqlalchemy.orm import Session 7 | from db.middleware.auth_middleware import get_current_user 8 | from secret_keys import SecretKeys 9 | import uuid 10 | 11 | router = APIRouter() 12 | secret_keys = SecretKeys() 13 | 14 | s3_client = boto3.client( 15 | "s3", 16 | region_name=secret_keys.REGION_NAME, 17 | ) 18 | 19 | 20 | @router.get("/url") 21 | def get_presigned_url(user=Depends(get_current_user)): 22 | try: 23 | video_id = f"videos/{user['sub']}/{uuid.uuid4()}.mp4" 24 | 25 | response = s3_client.generate_presigned_url( 26 | "put_object", 27 | Params={ 28 | "Bucket": secret_keys.AWS_RAW_VIDEOS_BUCKET, 29 | "Key": video_id, 30 | "ContentType": "video/mp4", 31 | }, 32 | ) 33 | print(response) 34 | 35 | return { 36 | "url": response, 37 | "video_id": video_id, 38 | } 39 | except Exception as e: 40 | raise HTTPException(500, str(e)) 41 | 42 | 43 | @router.get("/url/thumbnail") 44 | def get_presigned_url_thumbnail(thumbnail_id: str, user=Depends(get_current_user)): 45 | try: 46 | thumbnail_id = thumbnail_id.replace("videos/", "thumbnails/").replace( 47 | ".mp4", "" 48 | ) 49 | response = s3_client.generate_presigned_url( 50 | "put_object", 51 | Params={ 52 | "Bucket": secret_keys.AWS_VIDEO_THUMBNAIL_BUCKET, 53 | "Key": thumbnail_id, 54 | "ContentType": "image/jpg", 55 | "ACL": "public-read", 56 | }, 57 | ) 58 | print(response) 59 | 60 | return { 61 | "url": response, 62 | "thumbnail_id": thumbnail_id, 63 | } 64 | except Exception as e: 65 | raise HTTPException(500, str(e)) 66 | 67 | 68 | @router.post("/metadata") 69 | def upload_metadata( 70 | metadata: UploadMetadata, 71 | user=Depends(get_current_user), 72 | db: Session = Depends(get_db), 73 | ): 74 | new_video = Video( 75 | id=metadata.video_id, 76 | title=metadata.title, 77 | description=metadata.description, 78 | video_s3_key=metadata.video_s3_key, 79 | visibility=metadata.visibility, 80 | user_id=user["sub"], 81 | ) 82 | 83 | db.add(new_video) 84 | db.commit() 85 | db.refresh(new_video) 86 | 87 | return new_video 88 | -------------------------------------------------------------------------------- /backend/routes/video.py: -------------------------------------------------------------------------------- 1 | import json 2 | from fastapi import APIRouter, Depends, HTTPException 3 | from db.db import get_db 4 | from db.middleware.auth_middleware import get_current_user 5 | from db.models.video import ProcessingStatus, Video, VisibilityStatus 6 | from sqlalchemy.orm import Session 7 | from sqlalchemy import or_ 8 | from db.redis_db import redis_client 9 | 10 | router = APIRouter() 11 | 12 | 13 | @router.get("/all") 14 | def get_all_videos( 15 | db: Session = Depends(get_db), 16 | user=Depends( 17 | get_current_user, 18 | ), 19 | ): 20 | all_videos = ( 21 | db.query(Video) 22 | .filter( 23 | Video.is_processing == ProcessingStatus.COMPLETED, 24 | Video.visibility == VisibilityStatus.PUBLIC, 25 | ) 26 | .all() 27 | ) 28 | 29 | return all_videos 30 | 31 | 32 | @router.get("/") 33 | def get_video_info( 34 | video_id: str, 35 | db: Session = Depends(get_db), 36 | user=Depends( 37 | get_current_user, 38 | ), 39 | ): 40 | cache_key = f"video:{video_id}" 41 | cached_data = redis_client.get(cache_key) 42 | 43 | if cached_data: 44 | return json.loads(cached_data) 45 | 46 | video = ( 47 | db.query(Video) 48 | .filter( 49 | Video.id == video_id, 50 | Video.is_processing == ProcessingStatus.COMPLETED, 51 | or_( 52 | Video.visibility == VisibilityStatus.PUBLIC, 53 | Video.visibility == VisibilityStatus.UNLISTED, 54 | ), 55 | ) 56 | .first() 57 | ) 58 | 59 | redis_client.setex(cache_key, 3600, json.dumps(video.to_dict())) 60 | 61 | return video 62 | 63 | 64 | @router.put("/") 65 | def update_video_by_id(id: str, db: Session = Depends(get_db)): 66 | video = db.query(Video).filter(Video.id == id).first() 67 | 68 | if not video: 69 | raise HTTPException(404, "Video not found!") 70 | 71 | video.is_processing = ProcessingStatus.COMPLETED 72 | db.commit() 73 | db.refresh(video) 74 | 75 | return video 76 | -------------------------------------------------------------------------------- /backend/secret_keys.py: -------------------------------------------------------------------------------- 1 | from pydantic_settings import BaseSettings 2 | from dotenv import load_dotenv 3 | 4 | load_dotenv() 5 | 6 | 7 | class SecretKeys(BaseSettings): 8 | COGNITO_CLIENT_ID: str = "" 9 | COGNITO_CLIENT_SECRET: str = "" 10 | REGION_NAME: str = "" 11 | POSTGRES_DB_URL: str = "" 12 | AWS_RAW_VIDEOS_BUCKET: str = "" 13 | AWS_VIDEO_THUMBNAIL_BUCKET: str = "" 14 | -------------------------------------------------------------------------------- /consumer/.env.example: -------------------------------------------------------------------------------- 1 | REGION_NAME= 2 | AWS_SQS_VIDEO_PROCESSING= -------------------------------------------------------------------------------- /consumer/main.py: -------------------------------------------------------------------------------- 1 | import json 2 | import boto3 3 | from secret_keys import SecretKeys 4 | 5 | secret_keys = SecretKeys() 6 | sqs_client = boto3.client( 7 | "sqs", 8 | region_name=secret_keys.REGION_NAME, 9 | ) 10 | 11 | 12 | ecs_client = boto3.client( 13 | "ecs", 14 | region_name=secret_keys.REGION_NAME, 15 | ) 16 | 17 | 18 | def poll_sqs(): 19 | while True: 20 | response = sqs_client.receive_message( 21 | QueueUrl=secret_keys.AWS_SQS_VIDEO_PROCESSING, 22 | MaxNumberOfMessages=1, 23 | WaitTimeSeconds=10, 24 | ) 25 | 26 | for message in response.get("Messages", []): 27 | message_body = json.loads(message.get("Body")) 28 | 29 | if ( 30 | "Service" in message_body 31 | and "Event" in message_body 32 | and message_body.get("Event") == "s3:TestEvent" 33 | ): 34 | sqs_client.delete_message( 35 | QueueUrl=secret_keys.AWS_SQS_VIDEO_PROCESSING, 36 | ReceiptHandle=message["ReceiptHandle"], 37 | ) 38 | continue 39 | 40 | if "Records" in message_body: 41 | s3_record = message_body["Records"][0]["s3"] 42 | bucket_name = s3_record["bucket"]["name"] 43 | s3_key = s3_record["object"]["key"] 44 | 45 | response = ecs_client.run_task( 46 | cluster="arn:aws:ecs:ap-south-1:605134446036:cluster/Rivaan-TranscoderCluster", 47 | launchType="FARGATE", 48 | taskDefinition="arn:aws:ecs:ap-south-1:605134446036:task-definition/video-transcoder:2", 49 | overrides={ 50 | "containerOverrides": [ 51 | { 52 | "name": "video-transcoder", 53 | "environment": [ 54 | {"name": "S3_BUCKET", "value": bucket_name}, 55 | {"name": "S3_KEY", "value": s3_key}, 56 | ], 57 | } 58 | ] 59 | }, 60 | networkConfiguration={ 61 | "awsvpcConfiguration": { 62 | "subnets": [ 63 | "subnet-0c1cf3385363a7d66", 64 | "subnet-02bdfb9f47bd9b9a6", 65 | "subnet-0cacf7adeb5e67b96", 66 | ], 67 | "assignPublicIp": "ENABLED", 68 | "securityGroups": ["sg-0279fe5646343ea75"], 69 | } 70 | }, 71 | ) 72 | 73 | print(response) 74 | sqs_client.delete_message( 75 | QueueUrl=secret_keys.AWS_SQS_VIDEO_PROCESSING, 76 | ReceiptHandle=message["ReceiptHandle"], 77 | ) 78 | 79 | 80 | poll_sqs() 81 | -------------------------------------------------------------------------------- /consumer/requirements.txt: -------------------------------------------------------------------------------- 1 | boto3 2 | pydantic_settings 3 | python-dotenv -------------------------------------------------------------------------------- /consumer/secret_keys.py: -------------------------------------------------------------------------------- 1 | from pydantic_settings import BaseSettings 2 | from dotenv import load_dotenv 3 | 4 | load_dotenv() 5 | 6 | 7 | class SecretKeys(BaseSettings): 8 | REGION_NAME: str = "" 9 | AWS_SQS_VIDEO_PROCESSING: str = "" 10 | -------------------------------------------------------------------------------- /flutter_client/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .build/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | .swiftpm/ 13 | migrate_working_dir/ 14 | 15 | # IntelliJ related 16 | *.iml 17 | *.ipr 18 | *.iws 19 | .idea/ 20 | 21 | # The .vscode folder contains launch configuration and tasks you configure in 22 | # VS Code which you may wish to be included in version control, so this line 23 | # is commented out by default. 24 | #.vscode/ 25 | 26 | # Flutter/Dart/Pub related 27 | **/doc/api/ 28 | **/ios/Flutter/.last_build_id 29 | .dart_tool/ 30 | .flutter-plugins 31 | .flutter-plugins-dependencies 32 | .pub-cache/ 33 | .pub/ 34 | /build/ 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Obfuscation related 40 | app.*.map.json 41 | 42 | # Android Studio will place build artifacts here 43 | /android/app/debug 44 | /android/app/profile 45 | /android/app/release 46 | -------------------------------------------------------------------------------- /flutter_client/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "35c388afb57ef061d06a39b537336c87e0e3d1b1" 8 | channel: "stable" 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 17 | base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 18 | - platform: android 19 | create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 20 | base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 21 | - platform: ios 22 | create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 23 | base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 24 | - platform: linux 25 | create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 26 | base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 27 | - platform: macos 28 | create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 29 | base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 30 | - platform: web 31 | create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 32 | base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 33 | - platform: windows 34 | create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 35 | base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /flutter_client/README.md: -------------------------------------------------------------------------------- 1 | # flutter_client 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /flutter_client/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /flutter_client/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | .cxx/ 9 | 10 | # Remember to never publicly share your keystore. 11 | # See https://flutter.dev/to/reference-keystore 12 | key.properties 13 | **/*.keystore 14 | **/*.jks 15 | -------------------------------------------------------------------------------- /flutter_client/android/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 5 | id("dev.flutter.flutter-gradle-plugin") 6 | } 7 | 8 | android { 9 | namespace = "com.example.flutter_client" 10 | compileSdk = flutter.compileSdkVersion 11 | ndkVersion = flutter.ndkVersion 12 | 13 | compileOptions { 14 | sourceCompatibility = JavaVersion.VERSION_11 15 | targetCompatibility = JavaVersion.VERSION_11 16 | } 17 | 18 | kotlinOptions { 19 | jvmTarget = JavaVersion.VERSION_11.toString() 20 | } 21 | 22 | defaultConfig { 23 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 24 | applicationId = "com.example.flutter_client" 25 | // You can update the following values to match your application needs. 26 | // For more information, see: https://flutter.dev/to/review-gradle-config. 27 | minSdk = flutter.minSdkVersion 28 | targetSdk = flutter.targetSdkVersion 29 | versionCode = flutter.versionCode 30 | versionName = flutter.versionName 31 | } 32 | 33 | buildTypes { 34 | release { 35 | // TODO: Add your own signing config for the release build. 36 | // Signing with the debug keys for now, so `flutter run --release` works. 37 | signingConfig = signingConfigs.getByName("debug") 38 | } 39 | } 40 | } 41 | 42 | flutter { 43 | source = "../.." 44 | } 45 | -------------------------------------------------------------------------------- /flutter_client/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /flutter_client/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /flutter_client/android/app/src/main/kotlin/com/example/flutter_client/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.flutter_client 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity : FlutterActivity() 6 | -------------------------------------------------------------------------------- /flutter_client/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /flutter_client/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /flutter_client/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter_client/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter_client/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter_client/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter_client/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter_client/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /flutter_client/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /flutter_client/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /flutter_client/android/build.gradle.kts: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get() 9 | rootProject.layout.buildDirectory.value(newBuildDir) 10 | 11 | subprojects { 12 | val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) 13 | project.layout.buildDirectory.value(newSubprojectBuildDir) 14 | } 15 | subprojects { 16 | project.evaluationDependsOn(":app") 17 | } 18 | 19 | tasks.register("clean") { 20 | delete(rootProject.layout.buildDirectory) 21 | } 22 | -------------------------------------------------------------------------------- /flutter_client/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /flutter_client/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip 6 | -------------------------------------------------------------------------------- /flutter_client/android/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | val flutterSdkPath = run { 3 | val properties = java.util.Properties() 4 | file("local.properties").inputStream().use { properties.load(it) } 5 | val flutterSdkPath = properties.getProperty("flutter.sdk") 6 | require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } 7 | flutterSdkPath 8 | } 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id("dev.flutter.flutter-plugin-loader") version "1.0.0" 21 | id("com.android.application") version "8.7.0" apply false 22 | id("org.jetbrains.kotlin.android") version "1.8.22" apply false 23 | } 24 | 25 | include(":app") 26 | -------------------------------------------------------------------------------- /flutter_client/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /flutter_client/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 12.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /flutter_client/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /flutter_client/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /flutter_client/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '12.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | 33 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 34 | target 'RunnerTests' do 35 | inherit! :search_paths 36 | end 37 | end 38 | 39 | post_install do |installer| 40 | installer.pods_project.targets.each do |target| 41 | flutter_additional_ios_build_settings(target) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /flutter_client/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - better_player (0.0.1): 3 | - Cache (~> 6.0.0) 4 | - Flutter 5 | - GCDWebServer 6 | - HLSCachingReverseProxyServer 7 | - PINCache 8 | - Cache (6.0.0) 9 | - Flutter (1.0.0) 10 | - flutter_secure_storage (6.0.0): 11 | - Flutter 12 | - GCDWebServer (3.5.4): 13 | - GCDWebServer/Core (= 3.5.4) 14 | - GCDWebServer/Core (3.5.4) 15 | - HLSCachingReverseProxyServer (0.1.0): 16 | - GCDWebServer (~> 3.5) 17 | - PINCache (>= 3.0.1-beta.3) 18 | - image_picker_ios (0.0.1): 19 | - Flutter 20 | - package_info_plus (0.4.5): 21 | - Flutter 22 | - path_provider_foundation (0.0.1): 23 | - Flutter 24 | - FlutterMacOS 25 | - PINCache (3.0.4): 26 | - PINCache/Arc-exception-safe (= 3.0.4) 27 | - PINCache/Core (= 3.0.4) 28 | - PINCache/Arc-exception-safe (3.0.4): 29 | - PINCache/Core 30 | - PINCache/Core (3.0.4): 31 | - PINOperation (~> 1.2.3) 32 | - PINOperation (1.2.3) 33 | - wakelock_plus (0.0.1): 34 | - Flutter 35 | 36 | DEPENDENCIES: 37 | - better_player (from `.symlinks/plugins/better_player/ios`) 38 | - Flutter (from `Flutter`) 39 | - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) 40 | - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) 41 | - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) 42 | - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) 43 | - wakelock_plus (from `.symlinks/plugins/wakelock_plus/ios`) 44 | 45 | SPEC REPOS: 46 | trunk: 47 | - Cache 48 | - GCDWebServer 49 | - HLSCachingReverseProxyServer 50 | - PINCache 51 | - PINOperation 52 | 53 | EXTERNAL SOURCES: 54 | better_player: 55 | :path: ".symlinks/plugins/better_player/ios" 56 | Flutter: 57 | :path: Flutter 58 | flutter_secure_storage: 59 | :path: ".symlinks/plugins/flutter_secure_storage/ios" 60 | image_picker_ios: 61 | :path: ".symlinks/plugins/image_picker_ios/ios" 62 | package_info_plus: 63 | :path: ".symlinks/plugins/package_info_plus/ios" 64 | path_provider_foundation: 65 | :path: ".symlinks/plugins/path_provider_foundation/darwin" 66 | wakelock_plus: 67 | :path: ".symlinks/plugins/wakelock_plus/ios" 68 | 69 | SPEC CHECKSUMS: 70 | better_player: 472a1f3471b8991bde82327c91498b0f7934245d 71 | Cache: 4ca7e00363fca5455f26534e5607634c820ffc2d 72 | Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 73 | flutter_secure_storage: 1ed9476fba7e7a782b22888f956cce43e2c62f13 74 | GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4 75 | HLSCachingReverseProxyServer: 59935e1e0244ad7f3375d75b5ef46e8eb26ab181 76 | image_picker_ios: 7fe1ff8e34c1790d6fff70a32484959f563a928a 77 | package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499 78 | path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564 79 | PINCache: d9a87a0ff397acffe9e2f0db972ac14680441158 80 | PINOperation: fb563bcc9c32c26d6c78aaff967d405aa2ee74a7 81 | wakelock_plus: 04623e3f525556020ebd4034310f20fe7fda8b49 82 | 83 | PODFILE CHECKSUM: 4305caec6b40dde0ae97be1573c53de1882a07e5 84 | 85 | COCOAPODS: 1.16.2 86 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 64 | 66 | 72 | 73 | 74 | 75 | 81 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | @main 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Flutter Client 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutter_client 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | NSPhotoLibraryUsageDescription 49 | Access to gallery for thumbnail 50 | NSCameraUsageDescription 51 | Access to camera for thumbnail or for video 52 | NSMicrophoneUsageDescription 53 | Access to mic for video 54 | NSAppTransportSecurity 55 | 56 | NSAllowsArbitraryLoads 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /flutter_client/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /flutter_client/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /flutter_client/lib/cubits/auth/auth_cubit.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutter_client/services/auth_service.dart'; 4 | 5 | part 'auth_state.dart'; 6 | 7 | class AuthCubit extends Cubit { 8 | AuthCubit() : super(AuthInitial()); 9 | final AuthService authService = AuthService(); 10 | 11 | void signUpUser({ 12 | required String name, 13 | required String email, 14 | required String password, 15 | }) async { 16 | emit(AuthLoading()); 17 | try { 18 | final res = await authService.signUpUser( 19 | name: name, 20 | password: password, 21 | email: email, 22 | ); 23 | emit(AuthSignupSuccess(res)); 24 | } catch (e) { 25 | emit(AuthError(e.toString())); 26 | } 27 | } 28 | 29 | void confirmSignUpUser({required String email, required String otp}) async { 30 | emit(AuthLoading()); 31 | try { 32 | final res = await authService.confirmSignUpUser(email: email, otp: otp); 33 | emit(AuthConfirmSignupSuccess(res)); 34 | } catch (e) { 35 | emit(AuthError(e.toString())); 36 | } 37 | } 38 | 39 | void loginUser({required String email, required String password}) async { 40 | emit(AuthLoading()); 41 | try { 42 | final res = await authService.loginUser(password: password, email: email); 43 | emit(AuthLoginSuccess(res)); 44 | } catch (e) { 45 | emit(AuthError(e.toString())); 46 | } 47 | } 48 | 49 | void isAuthenticated() async { 50 | emit(AuthLoading()); 51 | try { 52 | final res = await authService.isAuthenticated(); 53 | if (res) { 54 | emit(AuthLoginSuccess('Logged in!')); 55 | } else { 56 | emit(AuthInitial()); 57 | } 58 | } catch (e) { 59 | emit(AuthError(e.toString())); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /flutter_client/lib/cubits/auth/auth_state.dart: -------------------------------------------------------------------------------- 1 | part of 'auth_cubit.dart'; 2 | 3 | @immutable 4 | sealed class AuthState {} 5 | 6 | final class AuthInitial extends AuthState {} 7 | 8 | final class AuthLoading extends AuthState {} 9 | 10 | final class AuthSignupSuccess extends AuthState { 11 | final String message; 12 | 13 | AuthSignupSuccess(this.message); 14 | } 15 | 16 | final class AuthLoginSuccess extends AuthState { 17 | final String message; 18 | 19 | AuthLoginSuccess(this.message); 20 | } 21 | 22 | final class AuthConfirmSignupSuccess extends AuthState { 23 | final String message; 24 | 25 | AuthConfirmSignupSuccess(this.message); 26 | } 27 | 28 | final class AuthError extends AuthState { 29 | final String error; 30 | AuthError(this.error); 31 | } 32 | -------------------------------------------------------------------------------- /flutter_client/lib/cubits/upload_video/upload_video_cubit.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutter_client/cubits/auth/auth_cubit.dart'; 4 | import 'package:flutter_client/services/upload_video_service.dart'; 5 | import 'package:path/path.dart' show dirname; 6 | import 'dart:io'; 7 | 8 | import 'package:path_provider/path_provider.dart'; 9 | part 'upload_video_state.dart'; 10 | 11 | class UploadVideoCubit extends Cubit { 12 | UploadVideoCubit() : super(UploadVideoInitial()); 13 | final uploadVideoService = UploadVideoService(); 14 | 15 | Future uploadVideo({ 16 | required File videoFile, 17 | required File thumbnailFile, 18 | required String title, 19 | required String description, 20 | required String visibility, 21 | }) async { 22 | emit(UploadVideoLoading()); 23 | try { 24 | final videoData = await uploadVideoService.getPresignedUrlForVideo(); 25 | final thumbnailData = await uploadVideoService 26 | .getPresignedUrlForThumbnail(videoData['video_id']); 27 | 28 | final appDir = await getApplicationDocumentsDirectory(); 29 | if (!appDir.existsSync()) { 30 | appDir.createSync(recursive: true); 31 | } 32 | 33 | final newThumbnailPath = 34 | "${appDir.path}/${thumbnailData['thumbnail_id']}"; 35 | final newVideoPath = "${appDir.path}/${videoData['video_id']}"; 36 | 37 | final thumbnailDir = Directory(dirname(newThumbnailPath)); 38 | final videoDir = Directory(dirname(newVideoPath)); 39 | 40 | if (!thumbnailDir.existsSync()) { 41 | thumbnailDir.createSync(recursive: true); 42 | } 43 | 44 | if (!videoDir.existsSync()) { 45 | videoDir.createSync(recursive: true); 46 | } 47 | 48 | File newThumbnailFile = await thumbnailFile.copy(newThumbnailPath); 49 | File newVideoFile = await videoFile.copy(newVideoPath); 50 | 51 | final isThumbnailUploaded = await uploadVideoService.uploadFileToS3( 52 | presignedUrl: thumbnailData['url'], 53 | file: newThumbnailFile, 54 | isVideo: false, 55 | ); 56 | 57 | final isVideoUploaded = await uploadVideoService.uploadFileToS3( 58 | presignedUrl: videoData['url'], 59 | file: newVideoFile, 60 | isVideo: true, 61 | ); 62 | 63 | if (isThumbnailUploaded && isVideoUploaded) { 64 | final isMetadataUploaded = await uploadVideoService.uploadMetadata( 65 | title: title, 66 | description: description, 67 | visibility: visibility, 68 | s3Key: videoData['video_id'], 69 | ); 70 | 71 | if (isMetadataUploaded) { 72 | emit(UploadVideoSuccess()); 73 | } else { 74 | emit(UploadVideoError('Metadata not uploaded to backend!')); 75 | } 76 | } else { 77 | emit(UploadVideoError('Files not uploaded to S3!')); 78 | } 79 | 80 | try { 81 | if (newThumbnailFile.existsSync()) { 82 | await newThumbnailFile.delete(); 83 | } 84 | if (newVideoFile.existsSync()) { 85 | await newVideoFile.delete(); 86 | } 87 | } catch (e) { 88 | print('Error cleaning up temp files: $e'); 89 | } 90 | } catch (e) { 91 | print('Upload error: $e'); 92 | emit(UploadVideoError(e.toString())); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /flutter_client/lib/cubits/upload_video/upload_video_state.dart: -------------------------------------------------------------------------------- 1 | part of 'upload_video_cubit.dart'; 2 | 3 | @immutable 4 | sealed class UploadVideoState { 5 | const UploadVideoState(); 6 | } 7 | 8 | final class UploadVideoInitial extends UploadVideoState {} 9 | 10 | final class UploadVideoLoading extends UploadVideoState {} 11 | 12 | final class UploadVideoSuccess extends UploadVideoState {} 13 | 14 | final class UploadVideoError extends UploadVideoState { 15 | final String error; 16 | const UploadVideoError(this.error); 17 | } 18 | -------------------------------------------------------------------------------- /flutter_client/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutter_client/cubits/auth/auth_cubit.dart'; 4 | import 'package:flutter_client/cubits/upload_video/upload_video_cubit.dart'; 5 | import 'package:flutter_client/pages/auth/signup_page.dart'; 6 | import 'package:flutter_client/pages/home/home_page.dart'; 7 | 8 | void main() { 9 | runApp( 10 | MultiBlocProvider( 11 | providers: [ 12 | BlocProvider(create: (context) => AuthCubit()), 13 | BlocProvider(create: (context) => UploadVideoCubit()), 14 | ], 15 | child: const MyApp(), 16 | ), 17 | ); 18 | } 19 | 20 | class MyApp extends StatefulWidget { 21 | const MyApp({super.key}); 22 | 23 | @override 24 | State createState() => _MyAppState(); 25 | } 26 | 27 | class _MyAppState extends State { 28 | @override 29 | void initState() { 30 | super.initState(); 31 | context.read().isAuthenticated(); 32 | } 33 | 34 | @override 35 | Widget build(BuildContext context) { 36 | return MaterialApp( 37 | title: 'YT Clone', 38 | theme: ThemeData( 39 | elevatedButtonTheme: ElevatedButtonThemeData( 40 | style: ElevatedButton.styleFrom( 41 | backgroundColor: Colors.black, 42 | minimumSize: Size(double.infinity, 60), 43 | shape: RoundedRectangleBorder( 44 | borderRadius: BorderRadius.circular(10), 45 | ), 46 | ), 47 | ), 48 | inputDecorationTheme: InputDecorationTheme( 49 | contentPadding: const EdgeInsets.all(27), 50 | enabledBorder: OutlineInputBorder( 51 | borderSide: BorderSide(color: Colors.grey.shade300, width: 3), 52 | borderRadius: BorderRadius.all(Radius.circular(5)), 53 | ), 54 | focusedBorder: OutlineInputBorder( 55 | borderSide: BorderSide(width: 3), 56 | borderRadius: BorderRadius.all(Radius.circular(5)), 57 | ), 58 | errorBorder: OutlineInputBorder( 59 | borderSide: BorderSide(color: Colors.red, width: 3), 60 | borderRadius: BorderRadius.all(Radius.circular(5)), 61 | ), 62 | border: OutlineInputBorder( 63 | borderSide: BorderSide(width: 3), 64 | borderRadius: BorderRadius.all(Radius.circular(5)), 65 | ), 66 | ), 67 | ), 68 | home: BlocBuilder( 69 | builder: (context, state) { 70 | if (state is AuthInitial) { 71 | return SignupPage(); 72 | } else if (state is AuthLoginSuccess) { 73 | return HomePage(); 74 | } else if (state is AuthError) { 75 | return SignupPage(); 76 | } 77 | 78 | return const SizedBox(); 79 | }, 80 | ), 81 | ); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /flutter_client/lib/pages/auth/confirm_signup_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutter_client/cubits/auth/auth_cubit.dart'; 4 | import 'package:flutter_client/pages/auth/login_page.dart'; 5 | import 'package:flutter_client/services/auth_service.dart'; 6 | import 'package:flutter_client/utils/utils.dart'; 7 | 8 | class ConfirmSignupPage extends StatefulWidget { 9 | final String email; 10 | static route(String email) => 11 | MaterialPageRoute(builder: (context) => ConfirmSignupPage(email: email)); 12 | const ConfirmSignupPage({super.key, required this.email}); 13 | 14 | @override 15 | State createState() => _ConfirmSignupPageState(); 16 | } 17 | 18 | class _ConfirmSignupPageState extends State { 19 | final otpController = TextEditingController(); 20 | late TextEditingController emailController; 21 | final formKey = GlobalKey(); 22 | final AuthService authService = AuthService(); 23 | 24 | @override 25 | void initState() { 26 | super.initState(); 27 | emailController = TextEditingController(text: widget.email); 28 | } 29 | 30 | @override 31 | void dispose() { 32 | otpController.dispose(); 33 | emailController.dispose(); 34 | super.dispose(); 35 | } 36 | 37 | void confirmSignUp() async { 38 | if (formKey.currentState!.validate()) { 39 | context.read().confirmSignUpUser( 40 | email: emailController.text.trim(), 41 | otp: otpController.text.trim(), 42 | ); 43 | } 44 | } 45 | 46 | @override 47 | Widget build(BuildContext context) { 48 | return Scaffold( 49 | body: BlocConsumer( 50 | listener: (context, state) { 51 | if (state is AuthConfirmSignupSuccess) { 52 | showSnackBar(state.message, context); 53 | Navigator.push(context, LoginPage.route()); 54 | } else if (state is AuthError) { 55 | showSnackBar(state.error, context); 56 | } 57 | }, 58 | builder: (context, state) { 59 | if (state is AuthLoading) { 60 | return Center(child: CircularProgressIndicator.adaptive()); 61 | } 62 | 63 | return Padding( 64 | padding: const EdgeInsets.all(15.0), 65 | child: Form( 66 | key: formKey, 67 | child: Column( 68 | mainAxisAlignment: MainAxisAlignment.center, 69 | children: [ 70 | Text( 71 | 'Confirm Sign Up', 72 | style: TextStyle(fontSize: 50, fontWeight: FontWeight.bold), 73 | ), 74 | const SizedBox(height: 30), 75 | TextFormField( 76 | controller: emailController, 77 | decoration: InputDecoration(hintText: 'Email'), 78 | validator: (value) { 79 | if (value != null && value.trim().isEmpty) { 80 | return "Field cannot be empty!"; 81 | } 82 | 83 | return null; 84 | }, 85 | ), 86 | const SizedBox(height: 15), 87 | TextFormField( 88 | controller: otpController, 89 | decoration: InputDecoration(hintText: 'OTP'), 90 | obscureText: true, 91 | validator: (value) { 92 | if (value != null && value.trim().isEmpty) { 93 | return "Field cannot be empty!"; 94 | } 95 | 96 | return null; 97 | }, 98 | ), 99 | const SizedBox(height: 20), 100 | ElevatedButton( 101 | onPressed: confirmSignUp, 102 | child: Text( 103 | 'CONFIRM', 104 | style: TextStyle(fontSize: 16, color: Colors.white), 105 | ), 106 | ), 107 | ], 108 | ), 109 | ), 110 | ); 111 | }, 112 | ), 113 | ); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /flutter_client/lib/pages/auth/login_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutter_client/cubits/auth/auth_cubit.dart'; 4 | import 'package:flutter_client/pages/auth/signup_page.dart'; 5 | import 'package:flutter_client/services/auth_service.dart'; 6 | import 'package:flutter_client/utils/utils.dart'; 7 | 8 | class LoginPage extends StatefulWidget { 9 | static route() => MaterialPageRoute(builder: (context) => LoginPage()); 10 | const LoginPage({super.key}); 11 | 12 | @override 13 | State createState() => _LoginPageState(); 14 | } 15 | 16 | class _LoginPageState extends State { 17 | final emailController = TextEditingController(); 18 | final passwordController = TextEditingController(); 19 | final formKey = GlobalKey(); 20 | final AuthService authService = AuthService(); 21 | 22 | @override 23 | void dispose() { 24 | passwordController.dispose(); 25 | emailController.dispose(); 26 | super.dispose(); 27 | } 28 | 29 | void login() async { 30 | if (formKey.currentState!.validate()) { 31 | context.read().loginUser( 32 | email: emailController.text.trim(), 33 | password: passwordController.text.trim(), 34 | ); 35 | } 36 | } 37 | 38 | @override 39 | Widget build(BuildContext context) { 40 | return Scaffold( 41 | body: BlocConsumer( 42 | listener: (context, state) { 43 | if (state is AuthLoginSuccess) { 44 | showSnackBar(state.message, context); 45 | // TODO: Navigate to home page 46 | } else if (state is AuthError) { 47 | showSnackBar(state.error, context); 48 | } 49 | }, 50 | builder: (context, state) { 51 | if (state is AuthLoading) { 52 | return Center(child: CircularProgressIndicator.adaptive()); 53 | } 54 | return Padding( 55 | padding: const EdgeInsets.all(15.0), 56 | child: Form( 57 | key: formKey, 58 | child: Column( 59 | mainAxisAlignment: MainAxisAlignment.center, 60 | children: [ 61 | Text( 62 | 'Sign in.', 63 | style: TextStyle(fontSize: 50, fontWeight: FontWeight.bold), 64 | ), 65 | const SizedBox(height: 30), 66 | TextFormField( 67 | controller: emailController, 68 | decoration: InputDecoration(hintText: 'Email'), 69 | validator: (value) { 70 | if (value != null && value.trim().isEmpty) { 71 | return "Field cannot be empty!"; 72 | } 73 | 74 | return null; 75 | }, 76 | ), 77 | const SizedBox(height: 15), 78 | TextFormField( 79 | controller: passwordController, 80 | decoration: InputDecoration(hintText: 'Password'), 81 | obscureText: true, 82 | validator: (value) { 83 | if (value != null && value.trim().isEmpty) { 84 | return "Field cannot be empty!"; 85 | } 86 | 87 | return null; 88 | }, 89 | ), 90 | const SizedBox(height: 20), 91 | ElevatedButton( 92 | onPressed: login, 93 | child: Text( 94 | 'SIGN IN', 95 | style: TextStyle(fontSize: 16, color: Colors.white), 96 | ), 97 | ), 98 | const SizedBox(height: 20), 99 | GestureDetector( 100 | onTap: () { 101 | Navigator.of(context).push(SignupPage.route()); 102 | }, 103 | child: RichText( 104 | text: TextSpan( 105 | text: 'Don\'t have an account? ', 106 | style: Theme.of(context).textTheme.titleMedium, 107 | children: [ 108 | TextSpan( 109 | text: 'Sign up', 110 | style: Theme.of(context).textTheme.titleMedium 111 | ?.copyWith(fontWeight: FontWeight.bold), 112 | ), 113 | ], 114 | ), 115 | ), 116 | ), 117 | ], 118 | ), 119 | ), 120 | ); 121 | }, 122 | ), 123 | ); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /flutter_client/lib/pages/auth/signup_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutter_client/cubits/auth/auth_cubit.dart'; 4 | import 'package:flutter_client/pages/auth/confirm_signup_page.dart'; 5 | import 'package:flutter_client/pages/auth/login_page.dart'; 6 | import 'package:flutter_client/services/auth_service.dart'; 7 | import 'package:flutter_client/utils/utils.dart'; 8 | 9 | class SignupPage extends StatefulWidget { 10 | static route() => MaterialPageRoute(builder: (context) => SignupPage()); 11 | const SignupPage({super.key}); 12 | 13 | @override 14 | State createState() => _SignupPageState(); 15 | } 16 | 17 | class _SignupPageState extends State { 18 | final nameController = TextEditingController(); 19 | final emailController = TextEditingController(); 20 | final passwordController = TextEditingController(); 21 | final formKey = GlobalKey(); 22 | 23 | @override 24 | void dispose() { 25 | nameController.dispose(); 26 | passwordController.dispose(); 27 | emailController.dispose(); 28 | super.dispose(); 29 | } 30 | 31 | void signUp() async { 32 | if (formKey.currentState!.validate()) { 33 | context.read().signUpUser( 34 | name: nameController.text.trim(), 35 | email: emailController.text.trim(), 36 | password: passwordController.text.trim(), 37 | ); 38 | } 39 | } 40 | 41 | @override 42 | Widget build(BuildContext context) { 43 | return Scaffold( 44 | body: BlocConsumer( 45 | listener: (context, state) { 46 | if (state is AuthSignupSuccess) { 47 | showSnackBar(state.message, context); 48 | Navigator.push( 49 | context, 50 | ConfirmSignupPage.route(emailController.text.trim()), 51 | ); 52 | } else if (state is AuthError) { 53 | showSnackBar(state.error, context); 54 | } 55 | }, 56 | builder: (context, state) { 57 | if (state is AuthLoading) { 58 | return Center(child: CircularProgressIndicator.adaptive()); 59 | } 60 | return Padding( 61 | padding: const EdgeInsets.all(15.0), 62 | child: Form( 63 | key: formKey, 64 | child: Column( 65 | mainAxisAlignment: MainAxisAlignment.center, 66 | children: [ 67 | Text( 68 | 'Sign Up', 69 | style: TextStyle(fontSize: 50, fontWeight: FontWeight.bold), 70 | ), 71 | const SizedBox(height: 30), 72 | TextFormField( 73 | controller: nameController, 74 | decoration: InputDecoration(hintText: 'Name'), 75 | validator: (value) { 76 | if (value != null && value.trim().isEmpty) { 77 | return "Field cannot be empty!"; 78 | } 79 | 80 | return null; 81 | }, 82 | ), 83 | const SizedBox(height: 15), 84 | TextFormField( 85 | controller: emailController, 86 | decoration: InputDecoration(hintText: 'Email'), 87 | validator: (value) { 88 | if (value != null && value.trim().isEmpty) { 89 | return "Field cannot be empty!"; 90 | } 91 | 92 | return null; 93 | }, 94 | ), 95 | const SizedBox(height: 15), 96 | TextFormField( 97 | controller: passwordController, 98 | decoration: InputDecoration(hintText: 'Password'), 99 | obscureText: true, 100 | validator: (value) { 101 | if (value != null && value.trim().isEmpty) { 102 | return "Field cannot be empty!"; 103 | } 104 | 105 | return null; 106 | }, 107 | ), 108 | const SizedBox(height: 20), 109 | ElevatedButton( 110 | onPressed: signUp, 111 | child: Text( 112 | 'SIGN UP', 113 | style: TextStyle(fontSize: 16, color: Colors.white), 114 | ), 115 | ), 116 | const SizedBox(height: 20), 117 | GestureDetector( 118 | onTap: () { 119 | Navigator.of(context).push(LoginPage.route()); 120 | }, 121 | child: RichText( 122 | text: TextSpan( 123 | text: 'Already have an account? ', 124 | style: Theme.of(context).textTheme.titleMedium, 125 | children: [ 126 | TextSpan( 127 | text: 'Sign In', 128 | style: Theme.of(context).textTheme.titleMedium 129 | ?.copyWith(fontWeight: FontWeight.bold), 130 | ), 131 | ], 132 | ), 133 | ), 134 | ), 135 | ], 136 | ), 137 | ), 138 | ); 139 | }, 140 | ), 141 | ); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /flutter_client/lib/pages/home/home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_client/pages/home/upload_page.dart'; 3 | import 'package:flutter_client/pages/home/video_player_page.dart'; 4 | import 'package:flutter_client/services/video_service.dart'; 5 | 6 | class HomePage extends StatefulWidget { 7 | const HomePage({super.key}); 8 | 9 | @override 10 | State createState() => _HomePageState(); 11 | } 12 | 13 | class _HomePageState extends State { 14 | final videosFuture = VideoService().getVideos(); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return Scaffold( 19 | appBar: AppBar( 20 | title: Text('Video Stream'), 21 | actions: [ 22 | IconButton( 23 | onPressed: () { 24 | Navigator.push(context, UploadPage.route()); 25 | }, 26 | icon: Icon(Icons.add), 27 | ), 28 | ], 29 | ), 30 | body: FutureBuilder( 31 | future: videosFuture, 32 | builder: (context, snapshot) { 33 | if (snapshot.connectionState == ConnectionState.waiting) { 34 | return Center(child: CircularProgressIndicator.adaptive()); 35 | } 36 | if (snapshot.hasError) { 37 | return Center(child: Text(snapshot.error.toString())); 38 | } 39 | final videos = snapshot.data!; 40 | 41 | return ListView.builder( 42 | itemCount: videos.length, 43 | itemBuilder: (context, index) { 44 | final video = videos[index]; 45 | final thumbnail = 46 | "https://d1unjxa15f7twa.cloudfront.net/${video['video_s3_key'].replaceAll('.mp4', "").replaceAll("videos/", "thumbnails/")}"; 47 | 48 | return GestureDetector( 49 | onTap: () { 50 | Navigator.push(context, VideoPlayerPage.route(video)); 51 | }, 52 | child: Padding( 53 | padding: const EdgeInsets.all(15.0), 54 | child: Column( 55 | crossAxisAlignment: CrossAxisAlignment.start, 56 | children: [ 57 | ClipRRect( 58 | borderRadius: BorderRadius.circular(15), 59 | child: AspectRatio( 60 | aspectRatio: 16 / 9, 61 | child: Image.network( 62 | thumbnail, 63 | fit: BoxFit.cover, 64 | headers: {'Content-Type': 'image/jpg'}, 65 | ), 66 | ), 67 | ), 68 | Padding( 69 | padding: const EdgeInsets.symmetric(horizontal: 10), 70 | child: Text( 71 | video['title'], 72 | style: TextStyle( 73 | fontSize: 20, 74 | fontWeight: FontWeight.bold, 75 | ), 76 | ), 77 | ), 78 | ], 79 | ), 80 | ), 81 | ); 82 | }, 83 | ); 84 | }, 85 | ), 86 | ); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /flutter_client/lib/pages/home/upload_page.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:dotted_border/dotted_border.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_bloc/flutter_bloc.dart'; 6 | import 'package:flutter_client/cubits/upload_video/upload_video_cubit.dart'; 7 | import 'package:flutter_client/utils/utils.dart'; 8 | 9 | class UploadPage extends StatefulWidget { 10 | static route() => MaterialPageRoute(builder: (context) => UploadPage()); 11 | const UploadPage({super.key}); 12 | 13 | @override 14 | State createState() => _UploadPageState(); 15 | } 16 | 17 | class _UploadPageState extends State { 18 | final descriptionController = TextEditingController(); 19 | final titleController = TextEditingController(); 20 | String visibility = 'PRIVATE'; 21 | File? imageFile; 22 | File? videoFile; 23 | 24 | @override 25 | void dispose() { 26 | descriptionController.dispose(); 27 | titleController.dispose(); 28 | super.dispose(); 29 | } 30 | 31 | void selectImage() async { 32 | final _imageFile = await pickImage(); 33 | 34 | setState(() { 35 | imageFile = _imageFile; 36 | }); 37 | } 38 | 39 | void selectVideo() async { 40 | final _videoFile = await pickVideo(); 41 | 42 | setState(() { 43 | videoFile = _videoFile; 44 | }); 45 | } 46 | 47 | void uploadVideo() async { 48 | if (titleController.text.trim().isNotEmpty && 49 | descriptionController.text.trim().isNotEmpty && 50 | videoFile != null && 51 | imageFile != null) { 52 | await context.read().uploadVideo( 53 | videoFile: videoFile!, 54 | thumbnailFile: imageFile!, 55 | title: titleController.text.trim(), 56 | description: descriptionController.text.trim(), 57 | visibility: visibility, 58 | ); 59 | } 60 | } 61 | 62 | @override 63 | Widget build(BuildContext context) { 64 | return Scaffold( 65 | appBar: AppBar(title: Text('Upload Page')), 66 | body: BlocConsumer( 67 | listener: (context, state) { 68 | if (state is UploadVideoSuccess) { 69 | showSnackBar('Video uploaded successfully!', context); 70 | Navigator.pop(context); 71 | } else if (state is UploadVideoError) { 72 | showSnackBar(state.error, context); 73 | } 74 | }, 75 | builder: (context, state) { 76 | if (state is UploadVideoLoading) { 77 | return Center(child: CircularProgressIndicator.adaptive()); 78 | } 79 | return SingleChildScrollView( 80 | child: Padding( 81 | padding: const EdgeInsets.all(20.0), 82 | child: Column( 83 | children: [ 84 | GestureDetector( 85 | onTap: selectImage, 86 | child: 87 | imageFile != null 88 | ? SizedBox( 89 | height: 150, 90 | width: double.infinity, 91 | child: Image.file(imageFile!, fit: BoxFit.cover), 92 | ) 93 | : DottedBorder( 94 | dashPattern: [10, 4], 95 | borderType: BorderType.RRect, 96 | strokeCap: StrokeCap.round, 97 | radius: Radius.circular(10), 98 | child: SizedBox( 99 | height: 150, 100 | width: double.infinity, 101 | child: Column( 102 | mainAxisAlignment: MainAxisAlignment.center, 103 | children: [ 104 | Icon(Icons.folder_open, size: 40), 105 | Text( 106 | 'Select the thumbnail for your video', 107 | style: TextStyle(fontSize: 15), 108 | ), 109 | ], 110 | ), 111 | ), 112 | ), 113 | ), 114 | const SizedBox(height: 15), 115 | GestureDetector( 116 | onTap: selectVideo, 117 | child: 118 | videoFile != null 119 | ? Text(videoFile!.path) 120 | : DottedBorder( 121 | dashPattern: [10, 4], 122 | borderType: BorderType.RRect, 123 | strokeCap: StrokeCap.round, 124 | radius: Radius.circular(10), 125 | child: SizedBox( 126 | height: 150, 127 | width: double.infinity, 128 | child: Column( 129 | mainAxisAlignment: MainAxisAlignment.center, 130 | children: [ 131 | Icon(Icons.video_file_outlined, size: 40), 132 | Text( 133 | 'Select your video file', 134 | style: TextStyle(fontSize: 15), 135 | ), 136 | ], 137 | ), 138 | ), 139 | ), 140 | ), 141 | const SizedBox(height: 15), 142 | TextField( 143 | controller: titleController, 144 | decoration: InputDecoration(hintText: 'Title'), 145 | ), 146 | const SizedBox(height: 15), 147 | TextField( 148 | controller: descriptionController, 149 | decoration: InputDecoration(hintText: 'Description'), 150 | maxLines: null, 151 | ), 152 | const SizedBox(height: 15), 153 | Container( 154 | width: double.infinity, 155 | decoration: BoxDecoration( 156 | border: Border.all(color: Colors.grey.shade300, width: 3), 157 | borderRadius: BorderRadius.circular(5), 158 | ), 159 | child: DropdownButton( 160 | value: visibility, 161 | padding: EdgeInsets.all(15), 162 | underline: SizedBox(), 163 | items: 164 | ['PUBLIC', 'PRIVATE', 'UNLISTED'] 165 | .map( 166 | (elem) => DropdownMenuItem( 167 | value: elem, 168 | child: Text(elem), 169 | ), 170 | ) 171 | .toList(), 172 | onChanged: (val) { 173 | setState(() { 174 | visibility = val!; 175 | }); 176 | }, 177 | ), 178 | ), 179 | SizedBox(height: 15), 180 | ElevatedButton( 181 | onPressed: uploadVideo, 182 | child: Text( 183 | 'UPLOAD', 184 | style: TextStyle(fontSize: 16, color: Colors.white), 185 | ), 186 | ), 187 | ], 188 | ), 189 | ), 190 | ); 191 | }, 192 | ), 193 | ); 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /flutter_client/lib/pages/home/video_player_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:better_player/better_player.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class VideoPlayerPage extends StatefulWidget { 5 | static route(Map video) => 6 | MaterialPageRoute(builder: (context) => VideoPlayerPage(video: video)); 7 | final Map video; 8 | const VideoPlayerPage({super.key, required this.video}); 9 | 10 | @override 11 | State createState() => _VideoPlayerPageState(); 12 | } 13 | 14 | class _VideoPlayerPageState extends State { 15 | late BetterPlayerController betterPlayerController; 16 | 17 | @override 18 | void initState() { 19 | super.initState(); 20 | betterPlayerController = BetterPlayerController( 21 | BetterPlayerConfiguration( 22 | aspectRatio: 16 / 9, 23 | fit: BoxFit.contain, 24 | autoPlay: true, 25 | controlsConfiguration: BetterPlayerControlsConfiguration( 26 | enableFullscreen: true, 27 | enablePlayPause: true, 28 | enableProgressBar: true, 29 | enablePlaybackSpeed: true, 30 | enableQualities: true, 31 | ), 32 | ), 33 | betterPlayerDataSource: BetterPlayerDataSource.network( 34 | "https://d3iiasefxo4uf9.cloudfront.net/${widget.video['video_s3_key']}/manifest.mpd", 35 | videoFormat: BetterPlayerVideoFormat.dash, 36 | ), 37 | ); 38 | } 39 | 40 | @override 41 | void dispose() { 42 | betterPlayerController.dispose(); 43 | super.dispose(); 44 | } 45 | 46 | @override 47 | Widget build(BuildContext context) { 48 | return Scaffold( 49 | body: Column( 50 | crossAxisAlignment: CrossAxisAlignment.start, 51 | children: [ 52 | BetterPlayer(controller: betterPlayerController), 53 | Padding( 54 | padding: const EdgeInsets.symmetric(horizontal: 10), 55 | child: Text( 56 | widget.video['title'], 57 | style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), 58 | ), 59 | ), 60 | Padding( 61 | padding: const EdgeInsets.all(10.0), 62 | child: Text(widget.video['description']), 63 | ), 64 | ], 65 | ), 66 | ); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /flutter_client/lib/services/auth_service.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_secure_storage/flutter_secure_storage.dart'; 4 | import 'package:http/http.dart' as http; 5 | 6 | class AuthService { 7 | final backendUrl = "http://35.23.52.233:8000/auth"; 8 | final FlutterSecureStorage secureStorage = FlutterSecureStorage(); 9 | 10 | Future> _getCookieHeader() async { 11 | final accessToken = await secureStorage.read(key: 'access_token'); 12 | final refreshToken = await secureStorage.read(key: 'refresh_token'); 13 | final userCognitoSub = await secureStorage.read(key: 'user_cognito_sub'); 14 | 15 | final headers = {'Content-Type': 'application/json'}; 16 | 17 | if (accessToken != null) { 18 | headers['Cookie'] = 'access_token=$accessToken'; 19 | 20 | if (refreshToken != null) { 21 | headers['Cookie'] = '${headers['Cookie']};refresh_token=$refreshToken'; 22 | if (userCognitoSub != null) { 23 | headers['Cookie'] = 24 | '${headers['Cookie']};user_cognito_sub=$userCognitoSub'; 25 | } 26 | } 27 | } 28 | 29 | return headers; 30 | } 31 | 32 | Future _storeCookies(http.Response response) async { 33 | String? cookies = response.headers['set-cookie']; 34 | 35 | if (cookies != null) { 36 | final accessTokenMatch = RegExp( 37 | r'access_token=([^;]+)', 38 | ).firstMatch(cookies); 39 | 40 | if (accessTokenMatch != null) { 41 | await secureStorage.write( 42 | key: 'access_token', 43 | value: accessTokenMatch.group(1), 44 | ); 45 | } 46 | 47 | final refreshTokenMatch = RegExp( 48 | r'refresh_token=([^;]+)', 49 | ).firstMatch(cookies); 50 | 51 | if (refreshTokenMatch != null) { 52 | await secureStorage.write( 53 | key: 'refresh_token', 54 | value: refreshTokenMatch.group(1), 55 | ); 56 | } 57 | } 58 | } 59 | 60 | Future signUpUser({ 61 | required String name, 62 | required String password, 63 | required String email, 64 | }) async { 65 | final res = await http.post( 66 | Uri.parse("$backendUrl/signup"), 67 | headers: {'Content-Type': 'application/json'}, 68 | body: jsonEncode({"name": name, "email": email, "password": password}), 69 | ); 70 | 71 | if (res.statusCode != 200) { 72 | print(res.body); 73 | throw jsonDecode(res.body)['detail'] ?? 'An error occurred!'; 74 | } 75 | 76 | print(res.headers); 77 | 78 | return jsonDecode(res.body)['message'] ?? 79 | 'Signup successful, please verify your email'; 80 | } 81 | 82 | Future confirmSignUpUser({ 83 | required String email, 84 | required String otp, 85 | }) async { 86 | final res = await http.post( 87 | Uri.parse("$backendUrl/confirm-signup"), 88 | headers: {'Content-Type': 'application/json'}, 89 | body: jsonEncode({"email": email, "otp": otp}), 90 | ); 91 | 92 | if (res.statusCode != 200) { 93 | print(res.body); 94 | throw jsonDecode(res.body)['detail'] ?? 'An error occurred!'; 95 | } 96 | 97 | return jsonDecode(res.body)['message'] ?? 'OTP Confirmed, LOGIN!'; 98 | } 99 | 100 | Future loginUser({ 101 | required String password, 102 | required String email, 103 | }) async { 104 | final res = await http.post( 105 | Uri.parse("$backendUrl/login"), 106 | headers: {'Content-Type': 'application/json'}, 107 | body: jsonEncode({"email": email, "password": password}), 108 | ); 109 | 110 | if (res.statusCode != 200) { 111 | print(res.body); 112 | throw jsonDecode(res.body)['detail'] ?? 'An error occurred!'; 113 | } 114 | await _storeCookies(res); 115 | isAuthenticated(); 116 | 117 | return jsonDecode(res.body)['message'] ?? 'Login successful'; 118 | } 119 | 120 | Future refreshToken() async { 121 | final cookieHeaders = await _getCookieHeader(); 122 | 123 | final res = await http.post( 124 | Uri.parse("$backendUrl/refresh"), 125 | headers: cookieHeaders, 126 | ); 127 | 128 | if (res.statusCode != 200) { 129 | throw jsonDecode(res.body)['detail'] ?? 'An error occurred!'; 130 | } 131 | await _storeCookies(res); 132 | 133 | return jsonDecode(res.body)['message'] ?? 'Login successful'; 134 | } 135 | 136 | Future isAuthenticated({int count = 0}) async { 137 | if (count > 1) { 138 | return false; 139 | } 140 | final cookieHeaders = await _getCookieHeader(); 141 | 142 | final res = await http.get( 143 | Uri.parse("$backendUrl/me"), 144 | headers: cookieHeaders, 145 | ); 146 | if (res.statusCode != 200) { 147 | await refreshToken(); 148 | isAuthenticated(count: count + 1); 149 | } else { 150 | await secureStorage.write( 151 | key: 'user_cognito_sub', 152 | value: jsonDecode(res.body)['user']['sub'], 153 | ); 154 | } 155 | return res.statusCode == 200; 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /flutter_client/lib/services/upload_video_service.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:io'; 3 | 4 | import 'package:flutter_secure_storage/flutter_secure_storage.dart'; 5 | import 'package:http/http.dart' as http; 6 | 7 | class UploadVideoService { 8 | final FlutterSecureStorage secureStorage = FlutterSecureStorage(); 9 | String backendUrl = "http://35.23.52.233:8000/upload/video"; 10 | 11 | Future> _getCookieHeader() async { 12 | final accessToken = await secureStorage.read(key: 'access_token'); 13 | 14 | final headers = {'Content-Type': 'application/json'}; 15 | 16 | if (accessToken != null) { 17 | headers['Cookie'] = 'access_token=$accessToken'; 18 | } 19 | 20 | return headers; 21 | } 22 | 23 | Future> getPresignedUrlForThumbnail( 24 | String thumbnailId, 25 | ) async { 26 | final res = await http.get( 27 | Uri.parse("$backendUrl/url/thumbnail?thumbnail_id=$thumbnailId"), 28 | headers: await _getCookieHeader(), 29 | ); 30 | 31 | if (res.statusCode == 200) { 32 | return jsonDecode(res.body) as Map; 33 | } 34 | 35 | throw jsonDecode(res.body)['detail'] ?? 'Unexpected error occurred'; 36 | } 37 | 38 | Future> getPresignedUrlForVideo() async { 39 | final res = await http.get( 40 | Uri.parse("$backendUrl/url"), 41 | headers: await _getCookieHeader(), 42 | ); 43 | 44 | if (res.statusCode == 200) { 45 | return jsonDecode(res.body) as Map; 46 | } 47 | 48 | throw jsonDecode(res.body)['detail'] ?? 'Unexpected error occurred'; 49 | } 50 | 51 | Future uploadFileToS3({ 52 | required String presignedUrl, 53 | required File file, 54 | required bool isVideo, 55 | }) async { 56 | final res = await http.put( 57 | Uri.parse(presignedUrl), 58 | headers: { 59 | 'Content-Type': isVideo ? 'video/mp4' : 'image/jpg', 60 | if (!isVideo) 'x-amz-acl': 'public-read', 61 | }, 62 | body: file.readAsBytesSync(), 63 | ); 64 | 65 | print(res.body); 66 | 67 | return res.statusCode == 200; 68 | } 69 | 70 | Future uploadMetadata({ 71 | required String title, 72 | required String description, 73 | required String visibility, 74 | required String s3Key, 75 | }) async { 76 | final res = await http.post( 77 | Uri.parse("$backendUrl/metadata"), 78 | headers: await _getCookieHeader(), 79 | body: jsonEncode({ 80 | 'title': title, 81 | 'description': description, 82 | 'visibility': visibility, 83 | 'video_id': s3Key, 84 | 'video_s3_key': s3Key, 85 | }), 86 | ); 87 | 88 | return res.statusCode == 200; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /flutter_client/lib/services/video_service.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_secure_storage/flutter_secure_storage.dart'; 4 | import 'package:http/http.dart' as http; 5 | 6 | class VideoService { 7 | final FlutterSecureStorage secureStorage = FlutterSecureStorage(); 8 | String backendUrl = "http://35.23.52.233:8000/videos"; 9 | 10 | Future> _getCookieHeader() async { 11 | final accessToken = await secureStorage.read(key: 'access_token'); 12 | 13 | final headers = {'Content-Type': 'application/json'}; 14 | 15 | if (accessToken != null) { 16 | headers['Cookie'] = 'access_token=$accessToken'; 17 | } 18 | 19 | return headers; 20 | } 21 | 22 | Future>> getVideos() async { 23 | try { 24 | final res = await http.get( 25 | Uri.parse("$backendUrl/all"), 26 | headers: await _getCookieHeader(), 27 | ); 28 | 29 | if (res.statusCode != 200) { 30 | throw jsonDecode(res.body)['detail'] ?? 'Error fetching videos!'; 31 | } 32 | 33 | return List>.from(jsonDecode(res.body)); 34 | } catch (e) { 35 | throw e.toString(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /flutter_client/lib/utils/utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter/widgets.dart'; 5 | import 'package:image_picker/image_picker.dart'; 6 | 7 | void showSnackBar(String content, BuildContext context) { 8 | ScaffoldMessenger.of(context) 9 | ..hideCurrentSnackBar() 10 | ..showSnackBar(SnackBar(content: Text(content))); 11 | } 12 | 13 | Future pickImage() async { 14 | final picker = ImagePicker(); 15 | 16 | final xFile = await picker.pickImage(source: ImageSource.gallery); 17 | 18 | if (xFile != null) { 19 | return File(xFile.path); 20 | } 21 | 22 | return null; 23 | } 24 | 25 | Future pickVideo() async { 26 | final picker = ImagePicker(); 27 | 28 | final xFile = await picker.pickVideo(source: ImageSource.gallery); 29 | 30 | if (xFile != null) { 31 | return File(xFile.path); 32 | } 33 | 34 | return null; 35 | } 36 | -------------------------------------------------------------------------------- /flutter_client/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /flutter_client/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.13) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "flutter_client") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.flutter_client") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | # Application build; see runner/CMakeLists.txt. 58 | add_subdirectory("runner") 59 | 60 | # Run the Flutter tool portions of the build. This must not be removed. 61 | add_dependencies(${BINARY_NAME} flutter_assemble) 62 | 63 | # Only the install-generated bundle's copy of the executable will launch 64 | # correctly, since the resources must in the right relative locations. To avoid 65 | # people trying to run the unbundled copy, put it in a subdirectory instead of 66 | # the default top-level location. 67 | set_target_properties(${BINARY_NAME} 68 | PROPERTIES 69 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 70 | ) 71 | 72 | 73 | # Generated plugin build rules, which manage building the plugins and adding 74 | # them to the application. 75 | include(flutter/generated_plugins.cmake) 76 | 77 | 78 | # === Installation === 79 | # By default, "installing" just makes a relocatable bundle in the build 80 | # directory. 81 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 82 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 83 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 84 | endif() 85 | 86 | # Start with a clean build bundle directory every time. 87 | install(CODE " 88 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 89 | " COMPONENT Runtime) 90 | 91 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 92 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 93 | 94 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 95 | COMPONENT Runtime) 96 | 97 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 98 | COMPONENT Runtime) 99 | 100 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 101 | COMPONENT Runtime) 102 | 103 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 104 | install(FILES "${bundled_library}" 105 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 106 | COMPONENT Runtime) 107 | endforeach(bundled_library) 108 | 109 | # Copy the native assets provided by the build.dart from all packages. 110 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") 111 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 112 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 113 | COMPONENT Runtime) 114 | 115 | # Fully re-copy the assets directory on each build to avoid having stale files 116 | # from a previous install. 117 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 118 | install(CODE " 119 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 120 | " COMPONENT Runtime) 121 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 122 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 123 | 124 | # Install the AOT library on non-Debug builds only. 125 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 126 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 127 | COMPONENT Runtime) 128 | endif() 129 | -------------------------------------------------------------------------------- /flutter_client/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /flutter_client/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | 12 | void fl_register_plugins(FlPluginRegistry* registry) { 13 | g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = 14 | fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); 15 | file_selector_plugin_register_with_registrar(file_selector_linux_registrar); 16 | g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar = 17 | fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin"); 18 | flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar); 19 | } 20 | -------------------------------------------------------------------------------- /flutter_client/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /flutter_client/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | file_selector_linux 7 | flutter_secure_storage_linux 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /flutter_client/linux/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} 10 | "main.cc" 11 | "my_application.cc" 12 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 13 | ) 14 | 15 | # Apply the standard set of build settings. This can be removed for applications 16 | # that need different build settings. 17 | apply_standard_settings(${BINARY_NAME}) 18 | 19 | # Add preprocessor definitions for the application ID. 20 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 21 | 22 | # Add dependency libraries. Add any application-specific dependencies here. 23 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 24 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 25 | 26 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 27 | -------------------------------------------------------------------------------- /flutter_client/linux/runner/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /flutter_client/linux/runner/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "flutter_client"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "flutter_client"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GApplication::startup. 85 | static void my_application_startup(GApplication* application) { 86 | //MyApplication* self = MY_APPLICATION(object); 87 | 88 | // Perform any actions required at application startup. 89 | 90 | G_APPLICATION_CLASS(my_application_parent_class)->startup(application); 91 | } 92 | 93 | // Implements GApplication::shutdown. 94 | static void my_application_shutdown(GApplication* application) { 95 | //MyApplication* self = MY_APPLICATION(object); 96 | 97 | // Perform any actions required at application shutdown. 98 | 99 | G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); 100 | } 101 | 102 | // Implements GObject::dispose. 103 | static void my_application_dispose(GObject* object) { 104 | MyApplication* self = MY_APPLICATION(object); 105 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 106 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 107 | } 108 | 109 | static void my_application_class_init(MyApplicationClass* klass) { 110 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 111 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 112 | G_APPLICATION_CLASS(klass)->startup = my_application_startup; 113 | G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; 114 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 115 | } 116 | 117 | static void my_application_init(MyApplication* self) {} 118 | 119 | MyApplication* my_application_new() { 120 | // Set the program name to the application ID, which helps various systems 121 | // like GTK and desktop environments map this running application to its 122 | // corresponding .desktop file. This ensures better integration by allowing 123 | // the application to be recognized beyond its binary name. 124 | g_set_prgname(APPLICATION_ID); 125 | 126 | return MY_APPLICATION(g_object_new(my_application_get_type(), 127 | "application-id", APPLICATION_ID, 128 | "flags", G_APPLICATION_NON_UNIQUE, 129 | nullptr)); 130 | } 131 | -------------------------------------------------------------------------------- /flutter_client/linux/runner/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /flutter_client/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /flutter_client/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /flutter_client/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /flutter_client/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import file_selector_macos 9 | import flutter_secure_storage_macos 10 | import package_info_plus 11 | import path_provider_foundation 12 | import wakelock_plus 13 | 14 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 15 | FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) 16 | FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) 17 | FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) 18 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 19 | WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) 20 | } 21 | -------------------------------------------------------------------------------- /flutter_client/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | 32 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 33 | target 'RunnerTests' do 34 | inherit! :search_paths 35 | end 36 | end 37 | 38 | post_install do |installer| 39 | installer.pods_project.targets.each do |target| 40 | flutter_additional_macos_build_settings(target) 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 64 | 66 | 72 | 73 | 74 | 75 | 81 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @main 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | 10 | override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { 11 | return true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = flutter_client 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterClient 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2025 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /flutter_client/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_client/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /flutter_client/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_client 2 | description: "A new Flutter project." 3 | # The following line prevents the package from being accidentally published to 4 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 5 | publish_to: "none" # Remove this line if you wish to publish to pub.dev 6 | 7 | # The following defines the version and build number for your application. 8 | # A version number is three numbers separated by dots, like 1.2.43 9 | # followed by an optional build number separated by a +. 10 | # Both the version and the builder number may be overridden in flutter 11 | # build by specifying --build-name and --build-number, respectively. 12 | # In Android, build-name is used as versionName while build-number used as versionCode. 13 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 14 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 15 | # Read more about iOS versioning at 16 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 17 | # In Windows, build-name is used as the major, minor, and patch parts 18 | # of the product and file versions while build-number is used as the build suffix. 19 | version: 1.0.0+1 20 | 21 | environment: 22 | sdk: ^3.7.0 23 | 24 | # Dependencies specify other packages that your package needs in order to work. 25 | # To automatically upgrade your package dependencies to the latest versions 26 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 27 | # dependencies can be manually updated by changing the version numbers below to 28 | # the latest version available on pub.dev. To see which dependencies have newer 29 | # versions available, run `flutter pub outdated`. 30 | dependencies: 31 | flutter: 32 | sdk: flutter 33 | 34 | # The following adds the Cupertino Icons font to your application. 35 | # Use with the CupertinoIcons class for iOS style icons. 36 | cupertino_icons: ^1.0.8 37 | http: ^1.3.0 38 | flutter_bloc: ^9.1.0 39 | flutter_secure_storage: ^9.2.4 40 | dotted_border: ^2.1.0 41 | image_picker: ^1.1.2 42 | path_provider: ^2.1.5 43 | path: ^1.9.1 44 | better_player: 45 | git: https://github.com/Lo4D/better-player-ultra.git 46 | 47 | dev_dependencies: 48 | flutter_test: 49 | sdk: flutter 50 | 51 | # The "flutter_lints" package below contains a set of recommended lints to 52 | # encourage good coding practices. The lint set provided by the package is 53 | # activated in the `analysis_options.yaml` file located at the root of your 54 | # package. See that file for information about deactivating specific lint 55 | # rules and activating additional ones. 56 | flutter_lints: ^5.0.0 57 | 58 | # For information on the generic Dart part of this file, see the 59 | # following page: https://dart.dev/tools/pub/pubspec 60 | 61 | # The following section is specific to Flutter packages. 62 | flutter: 63 | # The following line ensures that the Material Icons font is 64 | # included with your application, so that you can use the icons in 65 | # the material Icons class. 66 | uses-material-design: true 67 | 68 | # To add assets to your application, add an assets section, like this: 69 | # assets: 70 | # - images/a_dot_burr.jpeg 71 | # - images/a_dot_ham.jpeg 72 | 73 | # An image asset can refer to one or more resolution-specific "variants", see 74 | # https://flutter.dev/to/resolution-aware-images 75 | 76 | # For details regarding adding assets from package dependencies, see 77 | # https://flutter.dev/to/asset-from-package 78 | 79 | # To add custom fonts to your application, add a fonts section here, 80 | # in this "flutter" section. Each entry in this list should have a 81 | # "family" key with the font family name, and a "fonts" key with a 82 | # list giving the asset and other descriptors for the font. For 83 | # example: 84 | # fonts: 85 | # - family: Schyler 86 | # fonts: 87 | # - asset: fonts/Schyler-Regular.ttf 88 | # - asset: fonts/Schyler-Italic.ttf 89 | # style: italic 90 | # - family: Trajan Pro 91 | # fonts: 92 | # - asset: fonts/TrajanPro.ttf 93 | # - asset: fonts/TrajanPro_Bold.ttf 94 | # weight: 700 95 | # 96 | # For details regarding fonts from package dependencies, 97 | # see https://flutter.dev/to/font-from-package 98 | -------------------------------------------------------------------------------- /flutter_client/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:flutter_client/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /flutter_client/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/web/favicon.png -------------------------------------------------------------------------------- /flutter_client/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/web/icons/Icon-192.png -------------------------------------------------------------------------------- /flutter_client/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/web/icons/Icon-512.png -------------------------------------------------------------------------------- /flutter_client/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /flutter_client/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /flutter_client/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | flutter_client 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /flutter_client/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter_client", 3 | "short_name": "flutter_client", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /flutter_client/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /flutter_client/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(flutter_client LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "flutter_client") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(VERSION 3.14...3.25) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Copy the native assets provided by the build.dart from all packages. 91 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") 92 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 93 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 94 | COMPONENT Runtime) 95 | 96 | # Fully re-copy the assets directory on each build to avoid having stale files 97 | # from a previous install. 98 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 99 | install(CODE " 100 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 101 | " COMPONENT Runtime) 102 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 103 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 104 | 105 | # Install the AOT library on non-Debug builds only. 106 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 107 | CONFIGURATIONS Profile;Release 108 | COMPONENT Runtime) 109 | -------------------------------------------------------------------------------- /flutter_client/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # Set fallback configurations for older versions of the flutter tool. 14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 15 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 16 | endif() 17 | 18 | # === Flutter Library === 19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 20 | 21 | # Published to parent scope for install step. 22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 26 | 27 | list(APPEND FLUTTER_LIBRARY_HEADERS 28 | "flutter_export.h" 29 | "flutter_windows.h" 30 | "flutter_messenger.h" 31 | "flutter_plugin_registrar.h" 32 | "flutter_texture_registrar.h" 33 | ) 34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 35 | add_library(flutter INTERFACE) 36 | target_include_directories(flutter INTERFACE 37 | "${EPHEMERAL_DIR}" 38 | ) 39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 40 | add_dependencies(flutter flutter_assemble) 41 | 42 | # === Wrapper === 43 | list(APPEND CPP_WRAPPER_SOURCES_CORE 44 | "core_implementations.cc" 45 | "standard_codec.cc" 46 | ) 47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 49 | "plugin_registrar.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 52 | list(APPEND CPP_WRAPPER_SOURCES_APP 53 | "flutter_engine.cc" 54 | "flutter_view_controller.cc" 55 | ) 56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 57 | 58 | # Wrapper sources needed for a plugin. 59 | add_library(flutter_wrapper_plugin STATIC 60 | ${CPP_WRAPPER_SOURCES_CORE} 61 | ${CPP_WRAPPER_SOURCES_PLUGIN} 62 | ) 63 | apply_standard_settings(flutter_wrapper_plugin) 64 | set_target_properties(flutter_wrapper_plugin PROPERTIES 65 | POSITION_INDEPENDENT_CODE ON) 66 | set_target_properties(flutter_wrapper_plugin PROPERTIES 67 | CXX_VISIBILITY_PRESET hidden) 68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 69 | target_include_directories(flutter_wrapper_plugin PUBLIC 70 | "${WRAPPER_ROOT}/include" 71 | ) 72 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 73 | 74 | # Wrapper sources needed for the runner. 75 | add_library(flutter_wrapper_app STATIC 76 | ${CPP_WRAPPER_SOURCES_CORE} 77 | ${CPP_WRAPPER_SOURCES_APP} 78 | ) 79 | apply_standard_settings(flutter_wrapper_app) 80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 81 | target_include_directories(flutter_wrapper_app PUBLIC 82 | "${WRAPPER_ROOT}/include" 83 | ) 84 | add_dependencies(flutter_wrapper_app flutter_assemble) 85 | 86 | # === Flutter tool backend === 87 | # _phony_ is a non-existent file to force this command to run every time, 88 | # since currently there's no way to get a full input/output list from the 89 | # flutter tool. 90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 92 | add_custom_command( 93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 95 | ${CPP_WRAPPER_SOURCES_APP} 96 | ${PHONY_OUTPUT} 97 | COMMAND ${CMAKE_COMMAND} -E env 98 | ${FLUTTER_TOOL_ENVIRONMENT} 99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 100 | ${FLUTTER_TARGET_PLATFORM} $ 101 | VERBATIM 102 | ) 103 | add_custom_target(flutter_assemble DEPENDS 104 | "${FLUTTER_LIBRARY}" 105 | ${FLUTTER_LIBRARY_HEADERS} 106 | ${CPP_WRAPPER_SOURCES_CORE} 107 | ${CPP_WRAPPER_SOURCES_PLUGIN} 108 | ${CPP_WRAPPER_SOURCES_APP} 109 | ) 110 | -------------------------------------------------------------------------------- /flutter_client/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | 12 | void RegisterPlugins(flutter::PluginRegistry* registry) { 13 | FileSelectorWindowsRegisterWithRegistrar( 14 | registry->GetRegistrarForPlugin("FileSelectorWindows")); 15 | FlutterSecureStorageWindowsPluginRegisterWithRegistrar( 16 | registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); 17 | } 18 | -------------------------------------------------------------------------------- /flutter_client/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /flutter_client/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | file_selector_windows 7 | flutter_secure_storage_windows 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /flutter_client/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /flutter_client/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "flutter_client" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "flutter_client" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2025 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "flutter_client.exe" "\0" 98 | VALUE "ProductName", "flutter_client" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /flutter_client/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /flutter_client/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /flutter_client/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"flutter_client", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /flutter_client/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /flutter_client/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RivaanRanawat/video_streaming_app_tutorial/d1cf550d3f9144ebd7798e0cc8b659d5affd81b9/flutter_client/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /flutter_client/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /flutter_client/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | unsigned int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length == 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /flutter_client/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /flutter_client/windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "resource.h" 7 | 8 | namespace { 9 | 10 | /// Window attribute that enables dark mode window decorations. 11 | /// 12 | /// Redefined in case the developer's machine has a Windows SDK older than 13 | /// version 10.0.22000.0. 14 | /// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute 15 | #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE 16 | #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 17 | #endif 18 | 19 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 20 | 21 | /// Registry key for app theme preference. 22 | /// 23 | /// A value of 0 indicates apps should use dark mode. A non-zero or missing 24 | /// value indicates apps should use light mode. 25 | constexpr const wchar_t kGetPreferredBrightnessRegKey[] = 26 | L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; 27 | constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; 28 | 29 | // The number of Win32Window objects that currently exist. 30 | static int g_active_window_count = 0; 31 | 32 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 33 | 34 | // Scale helper to convert logical scaler values to physical using passed in 35 | // scale factor 36 | int Scale(int source, double scale_factor) { 37 | return static_cast(source * scale_factor); 38 | } 39 | 40 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 41 | // This API is only needed for PerMonitor V1 awareness mode. 42 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 43 | HMODULE user32_module = LoadLibraryA("User32.dll"); 44 | if (!user32_module) { 45 | return; 46 | } 47 | auto enable_non_client_dpi_scaling = 48 | reinterpret_cast( 49 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 50 | if (enable_non_client_dpi_scaling != nullptr) { 51 | enable_non_client_dpi_scaling(hwnd); 52 | } 53 | FreeLibrary(user32_module); 54 | } 55 | 56 | } // namespace 57 | 58 | // Manages the Win32Window's window class registration. 59 | class WindowClassRegistrar { 60 | public: 61 | ~WindowClassRegistrar() = default; 62 | 63 | // Returns the singleton registrar instance. 64 | static WindowClassRegistrar* GetInstance() { 65 | if (!instance_) { 66 | instance_ = new WindowClassRegistrar(); 67 | } 68 | return instance_; 69 | } 70 | 71 | // Returns the name of the window class, registering the class if it hasn't 72 | // previously been registered. 73 | const wchar_t* GetWindowClass(); 74 | 75 | // Unregisters the window class. Should only be called if there are no 76 | // instances of the window. 77 | void UnregisterWindowClass(); 78 | 79 | private: 80 | WindowClassRegistrar() = default; 81 | 82 | static WindowClassRegistrar* instance_; 83 | 84 | bool class_registered_ = false; 85 | }; 86 | 87 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 88 | 89 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 90 | if (!class_registered_) { 91 | WNDCLASS window_class{}; 92 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 93 | window_class.lpszClassName = kWindowClassName; 94 | window_class.style = CS_HREDRAW | CS_VREDRAW; 95 | window_class.cbClsExtra = 0; 96 | window_class.cbWndExtra = 0; 97 | window_class.hInstance = GetModuleHandle(nullptr); 98 | window_class.hIcon = 99 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 100 | window_class.hbrBackground = 0; 101 | window_class.lpszMenuName = nullptr; 102 | window_class.lpfnWndProc = Win32Window::WndProc; 103 | RegisterClass(&window_class); 104 | class_registered_ = true; 105 | } 106 | return kWindowClassName; 107 | } 108 | 109 | void WindowClassRegistrar::UnregisterWindowClass() { 110 | UnregisterClass(kWindowClassName, nullptr); 111 | class_registered_ = false; 112 | } 113 | 114 | Win32Window::Win32Window() { 115 | ++g_active_window_count; 116 | } 117 | 118 | Win32Window::~Win32Window() { 119 | --g_active_window_count; 120 | Destroy(); 121 | } 122 | 123 | bool Win32Window::Create(const std::wstring& title, 124 | const Point& origin, 125 | const Size& size) { 126 | Destroy(); 127 | 128 | const wchar_t* window_class = 129 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 130 | 131 | const POINT target_point = {static_cast(origin.x), 132 | static_cast(origin.y)}; 133 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 134 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 135 | double scale_factor = dpi / 96.0; 136 | 137 | HWND window = CreateWindow( 138 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW, 139 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 140 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 141 | nullptr, nullptr, GetModuleHandle(nullptr), this); 142 | 143 | if (!window) { 144 | return false; 145 | } 146 | 147 | UpdateTheme(window); 148 | 149 | return OnCreate(); 150 | } 151 | 152 | bool Win32Window::Show() { 153 | return ShowWindow(window_handle_, SW_SHOWNORMAL); 154 | } 155 | 156 | // static 157 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 158 | UINT const message, 159 | WPARAM const wparam, 160 | LPARAM const lparam) noexcept { 161 | if (message == WM_NCCREATE) { 162 | auto window_struct = reinterpret_cast(lparam); 163 | SetWindowLongPtr(window, GWLP_USERDATA, 164 | reinterpret_cast(window_struct->lpCreateParams)); 165 | 166 | auto that = static_cast(window_struct->lpCreateParams); 167 | EnableFullDpiSupportIfAvailable(window); 168 | that->window_handle_ = window; 169 | } else if (Win32Window* that = GetThisFromHandle(window)) { 170 | return that->MessageHandler(window, message, wparam, lparam); 171 | } 172 | 173 | return DefWindowProc(window, message, wparam, lparam); 174 | } 175 | 176 | LRESULT 177 | Win32Window::MessageHandler(HWND hwnd, 178 | UINT const message, 179 | WPARAM const wparam, 180 | LPARAM const lparam) noexcept { 181 | switch (message) { 182 | case WM_DESTROY: 183 | window_handle_ = nullptr; 184 | Destroy(); 185 | if (quit_on_close_) { 186 | PostQuitMessage(0); 187 | } 188 | return 0; 189 | 190 | case WM_DPICHANGED: { 191 | auto newRectSize = reinterpret_cast(lparam); 192 | LONG newWidth = newRectSize->right - newRectSize->left; 193 | LONG newHeight = newRectSize->bottom - newRectSize->top; 194 | 195 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 196 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 197 | 198 | return 0; 199 | } 200 | case WM_SIZE: { 201 | RECT rect = GetClientArea(); 202 | if (child_content_ != nullptr) { 203 | // Size and position the child window. 204 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 205 | rect.bottom - rect.top, TRUE); 206 | } 207 | return 0; 208 | } 209 | 210 | case WM_ACTIVATE: 211 | if (child_content_ != nullptr) { 212 | SetFocus(child_content_); 213 | } 214 | return 0; 215 | 216 | case WM_DWMCOLORIZATIONCOLORCHANGED: 217 | UpdateTheme(hwnd); 218 | return 0; 219 | } 220 | 221 | return DefWindowProc(window_handle_, message, wparam, lparam); 222 | } 223 | 224 | void Win32Window::Destroy() { 225 | OnDestroy(); 226 | 227 | if (window_handle_) { 228 | DestroyWindow(window_handle_); 229 | window_handle_ = nullptr; 230 | } 231 | if (g_active_window_count == 0) { 232 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 233 | } 234 | } 235 | 236 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 237 | return reinterpret_cast( 238 | GetWindowLongPtr(window, GWLP_USERDATA)); 239 | } 240 | 241 | void Win32Window::SetChildContent(HWND content) { 242 | child_content_ = content; 243 | SetParent(content, window_handle_); 244 | RECT frame = GetClientArea(); 245 | 246 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 247 | frame.bottom - frame.top, true); 248 | 249 | SetFocus(child_content_); 250 | } 251 | 252 | RECT Win32Window::GetClientArea() { 253 | RECT frame; 254 | GetClientRect(window_handle_, &frame); 255 | return frame; 256 | } 257 | 258 | HWND Win32Window::GetHandle() { 259 | return window_handle_; 260 | } 261 | 262 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 263 | quit_on_close_ = quit_on_close; 264 | } 265 | 266 | bool Win32Window::OnCreate() { 267 | // No-op; provided for subclasses. 268 | return true; 269 | } 270 | 271 | void Win32Window::OnDestroy() { 272 | // No-op; provided for subclasses. 273 | } 274 | 275 | void Win32Window::UpdateTheme(HWND const window) { 276 | DWORD light_mode; 277 | DWORD light_mode_size = sizeof(light_mode); 278 | LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, 279 | kGetPreferredBrightnessRegValue, 280 | RRF_RT_REG_DWORD, nullptr, &light_mode, 281 | &light_mode_size); 282 | 283 | if (result == ERROR_SUCCESS) { 284 | BOOL enable_dark_mode = light_mode == 0; 285 | DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, 286 | &enable_dark_mode, sizeof(enable_dark_mode)); 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /flutter_client/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | -------------------------------------------------------------------------------- /transcoder/.env.example: -------------------------------------------------------------------------------- 1 | AWS_ACCESS_KEY_ID= 2 | AWS_SECRET_ACCESS_KEY= 3 | REGION_NAME= 4 | S3_PROCESSED_VIDEOS_BUCKET= 5 | BACKEND_URL= -------------------------------------------------------------------------------- /transcoder/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.11-slim 2 | 3 | RUN apt-get update && apt-get install -y ffmpeg && apt-get clean && rm -rf var/lib/apt/lists/* 4 | 5 | WORKDIR /app 6 | 7 | COPY requirements.txt . 8 | 9 | RUN pip install --no-cache-dir -r requirements.txt 10 | 11 | COPY . . 12 | 13 | CMD ["python", "main.py"] -------------------------------------------------------------------------------- /transcoder/main.py: -------------------------------------------------------------------------------- 1 | import os 2 | from pathlib import Path 3 | import boto3 4 | import requests 5 | from secret_keys import SecretKeys 6 | import subprocess 7 | 8 | secret_keys = SecretKeys() 9 | 10 | 11 | class VideoTranscoder: 12 | def __init__(self): 13 | self.s3_client = boto3.client( 14 | "s3", 15 | region_name=secret_keys.REGION_NAME, 16 | aws_access_key_id=secret_keys.AWS_ACCESS_KEY_ID, 17 | aws_secret_access_key=secret_keys.AWS_SECRET_ACCESS_KEY, 18 | ) 19 | 20 | def _get_content_type(self, file_path: str): 21 | if file_path.endswith(".m3u8"): 22 | return "application/vnd.apple.mpegurl" 23 | elif file_path.endswith(".ts"): 24 | return "video/MP2T" 25 | elif file_path.endswith(".mpd"): 26 | return "application/dash+xml" 27 | elif file_path.endswith(".m4s"): 28 | return "video/mp4" 29 | 30 | def download_video(self, local_path): 31 | self.s3_client.download_file( 32 | secret_keys.S3_BUCKET, 33 | secret_keys.S3_KEY, 34 | local_path, 35 | ) 36 | 37 | def transcode_video(self, input_path, output_dir): 38 | # HLS 39 | # cmd = [ 40 | # "ffmpeg", 41 | # "-i", 42 | # input_path, 43 | # "-filter_complex", 44 | # "[0:v]split=3[v1][v2][v3];" 45 | # "[v1]scale=640:360:flags=fast_bilinear[360p];" 46 | # "[v2]scale=1280:720:flags=fast_bilinear[720p];" 47 | # "[v3]scale=1920:1080:flags=fast_bilinear[1080p]", 48 | # "-map", 49 | # "[360p]", 50 | # "-map", 51 | # "[720p]", 52 | # "-map", 53 | # "[1080p]", 54 | # "-c:v", 55 | # "libx264", 56 | # "-preset", 57 | # "veryfast", 58 | # "-profile:v", 59 | # "high", 60 | # "-level:v", 61 | # "4.1", 62 | # "-g", 63 | # "48", 64 | # "-keyint_min", 65 | # "48", 66 | # "-sc_threshold", 67 | # "0", 68 | # "-b:v:0", 69 | # "1000k", 70 | # "-b:v:1", 71 | # "4000k", 72 | # "-b:v:2", 73 | # "8000k", 74 | # "-f", 75 | # "hls", 76 | # "-hls_time", 77 | # "6", 78 | # "-hls_playlist_type", 79 | # "vod", 80 | # "-hls_flags", 81 | # "independent_segments", 82 | # "-hls_segment_type", 83 | # "mpegts", 84 | # "-hls_list_size", 85 | # "0", 86 | # "-master_pl_name", 87 | # "master.m3u8", 88 | # "-var_stream_map", 89 | # "v:0 v:1 v:2", 90 | # "-hls_segment_filename", 91 | # f"{output_dir}/%v/segment_%03d.ts", 92 | # f"{output_dir}/%v/playlist.m3u8", 93 | # ] 94 | 95 | # DASH 96 | cmd = [ 97 | "ffmpeg", 98 | "-i", 99 | input_path, 100 | "-filter_complex", 101 | "[0:v]split=3[v1][v2][v3];" 102 | "[v1]scale=640:360:flags=fast_bilinear[360p];" 103 | "[v2]scale=1280:720:flags=fast_bilinear[720p];" 104 | "[v3]scale=1920:1080:flags=fast_bilinear[1080p]", 105 | # 360p video stream 106 | "-map", 107 | "[360p]", 108 | "-c:v:0", 109 | "libx264", 110 | "-b:v:0", 111 | "1000k", 112 | "-preset", 113 | "veryfast", 114 | "-profile:v", 115 | "high", 116 | "-level:v", 117 | "4.1", 118 | "-g", 119 | "48", 120 | "-keyint_min", 121 | "48", 122 | # 720p video stream 123 | "-map", 124 | "[720p]", 125 | "-c:v:1", 126 | "libx264", 127 | "-b:v:1", 128 | "4000k", 129 | "-preset", 130 | "veryfast", 131 | "-profile:v", 132 | "high", 133 | "-level:v", 134 | "4.1", 135 | "-g", 136 | "48", 137 | "-keyint_min", 138 | "48", 139 | # 1080p video stream 140 | "-map", 141 | "[1080p]", 142 | "-c:v:2", 143 | "libx264", 144 | "-b:v:2", 145 | "8000k", 146 | "-preset", 147 | "veryfast", 148 | "-profile:v", 149 | "high", 150 | "-level:v", 151 | "4.1", 152 | "-g", 153 | "48", 154 | "-keyint_min", 155 | "48", 156 | # Audio stream 157 | "-map", 158 | "0:a", 159 | "-c:a", 160 | "aac", 161 | "-b:a", 162 | "128k", 163 | # DASH specific settings 164 | "-use_timeline", 165 | "1", 166 | "-use_template", 167 | "1", 168 | "-window_size", 169 | "5", 170 | "-adaptation_sets", 171 | "id=0,streams=v id=1,streams=a", 172 | "-f", 173 | "dash", 174 | f"{output_dir}/manifest.mpd", 175 | ] 176 | process = subprocess.run(cmd) 177 | 178 | if process.returncode != 0: 179 | print(process.stderr) 180 | raise Exception("Transcoding failed!") 181 | 182 | def upload_files(self, prefix: str, local_dir): 183 | for root, _, files in os.walk(local_dir): 184 | for file in files: 185 | local_path = os.path.join(root, file) 186 | s3_key = f"{prefix}/{os.path.relpath(local_path, local_dir)}" 187 | self.s3_client.upload_file( 188 | local_path, 189 | secret_keys.S3_PROCESSED_VIDEOS_BUCKET, 190 | s3_key, 191 | ExtraArgs={ 192 | "ACL": "public-read", 193 | "ContentType": self._get_content_type(local_path), 194 | }, 195 | ) 196 | 197 | def process_video(self): 198 | work_dir = Path("/tmp/workspace") 199 | work_dir.mkdir(exist_ok=True) 200 | input_path = work_dir / "input.mp4" 201 | output_path = work_dir / "output" 202 | output_path.mkdir(exist_ok=True) 203 | try: 204 | self.download_video(input_path) 205 | self.transcode_video(str(input_path), str(output_path)) 206 | self.upload_files(secret_keys.S3_KEY, str(output_path)) 207 | self.update_video() 208 | finally: 209 | if input_path.exists(): 210 | input_path.unlink() 211 | if output_path.exists(): 212 | import shutil 213 | 214 | shutil.rmtree(str(output_path)) 215 | 216 | def update_video(self): 217 | try: 218 | response = requests.put( 219 | f"{secret_keys.BACKEND_URL}/videos?id={secret_keys.S3_KEY}" 220 | ) 221 | print(response.json()) 222 | return response.json() 223 | except Exception as e: 224 | print(e) 225 | 226 | 227 | VideoTranscoder().process_video() 228 | -------------------------------------------------------------------------------- /transcoder/requirements.txt: -------------------------------------------------------------------------------- 1 | boto3 2 | pydantic_settings 3 | python-dotenv 4 | requests -------------------------------------------------------------------------------- /transcoder/secret_keys.py: -------------------------------------------------------------------------------- 1 | from pydantic_settings import BaseSettings 2 | from dotenv import load_dotenv 3 | 4 | load_dotenv() 5 | 6 | 7 | class SecretKeys(BaseSettings): 8 | REGION_NAME: str = "" 9 | AWS_ACCESS_KEY_ID: str = "" 10 | AWS_SECRET_ACCESS_KEY: str = "" 11 | S3_BUCKET: str = "" 12 | S3_KEY: str = "" 13 | S3_PROCESSED_VIDEOS_BUCKET: str = "" 14 | BACKEND_URL: str = "" 15 | --------------------------------------------------------------------------------