This is a library for setting up broadcasts and streaming on Caffeine.tv.
Libcaffeine is licensed under the GNU GPL version 2. See LICENSE.txt for details.
For information on contributing to this project, see CONTRIBUTING.md.
TODO: More Documentation
Minimal Example:
// Callbacks
void started(void *myContext) {
// Start capturing audio & video
}
void failed(void *myContext, caff_Result result) {
// Handle error
// Stop capturing if necessary
}
// Once on startup
caff_initialize("example", "1.0", caff_SeverityDebug, NULL);
// Starting a broadcast
caff_InstanceHandle instance = caff_createInstance();
caff_Result result = caff_signIn(instance, "Myuser", "|\\/|Yp455WYrd", NULL);
if (result != caff_ResultSuccess) return -1;
result = caff_startBroadcast(instance, &myContext, "My title!", caff_RatingNone, NULL, started, failed);
// On your video/audio capture thread(s)
caff_sendVideo(
instance, caff_VideoFormatNv12, pixels, pixelBytes, width, height, caff_TimestampGenerate);
caff_sendAudio(instance, samples, 2);
// When it's over:
caff_endBroadcast(instance);
caff_freeInstance(&instance);
Prereqs:
- Visual Studio 2019 with "Desktop development with C++" selected and "C++ Clang tools for Windows" installed.
Steps:
- Download the latest version of webrtc-prebuilt-windows.7z from https://github.com/caffeinetv/webrtc/releases
- Extract the file somewhere convenient
- Set
WEBRTC_ROOT_DIR
environment variable to the directory you extracted the files to - Download obsdeps "https://obsproject.com/downloads/dependencies2019.zip" . Extract file
- Set
DepsPath
environment variable to directory you extracted files to. This is needed to get curl - In the libcaffeine root directory:
mkdir build64
cmake -H. -Bbuild64 -G "Visual Studio 16 2019" -A "x64" -T "ClangCL" -D BUILD_TESTS=OFF -DWEBRTC_ROOT_DIR="%WEBRTC_ROOT_DIR%" -DDepsPath="%DepsPath%\win64\include" -DCMAKE_INSTALL_PREFIX=dist -DCMAKE_C_COMPILER="%VSINSTALLATION%/VC/Tools/Llvm/bin/clang.exe" -DCMAKE_CXX_COMPILER="%VSINSTALLATION%/VC/Tools/Llvm/bin/clang++.exe"
start libcaffeine.sln
- Build the solution in Visual Studio
Prereqs:
- Xcode
- CMAKE
Steps:
- Download the latest version of webrtc-prebuilt-macos.7z from https://github.com/caffeinetv/webrtc/releases
- Extract the archive somewhere convenient
- Set
WEBRTC_ROOT_DIR
environment variable to the directory you extracted the files to - In the libcaffeine root directory:
mkdir build
cd build
cmake .. -G Xcode
- Build the project in Xcode
Note: if the cmake command above fails, it may be due to the XCode commandline tools being selected. To resolve this, reset your XCode selection and retry: sudo xcode-select -r
TODO: Linux
To run the build
- Download 7z
- Add 7z.exe to system Path env variable.
- Add msbuild binary to system PATH env var
- Add cmake binary to system PATH env var.
- Add LLVM bin to system PATH env var.
- Install using homebrew
brew install p7zip
Change directory to be the libcaffeine directory.
- Run the automated script in command prompt
build.bat [OPTION]
- Run the automated script in Terminal
sh build.sh [OPTION]
Supported options
Options | Usage
------------- | -------------
-check | To check project prerequisites
-build | Builds the project
-package | Packages libcaffein with 7z
-buildAndPackage| Builds and packages libcaffeine.
The packaged output will be in build
directory in Mac and dist directory in Windows.
- Build libcaffeine for both 32- and 64-bit windows
- Create a folder named libcaffeine-vX.Y-windows
- Inside that create these folders:
- bin32
- bin64
- include
- lib32
- lib64
- Copy caffeine.h into include
- Copy the .dll and .pdb files into the binXX folders
- Copy the .lib files into the libXX folders
- From
CMakeFiles/Export/libXX/cmake
folder copylibcaffeineTarget.cmake
,libcaffeineTarget-debug.cmake
,libcaffeineTarget-debug.cmake
into libXX/cmake - Copy libcaffeineConfig.cmake into libXX/cmake
- Copy libcaffeineConfigVersion.cmake into libXX/cmake
- 7z a libcaffeine-vX.Y-windows libcaffeine-vX.Y-windows.7z
- Build for macOS
- Create a folder named libcaffeine-vX.Y-macos
- Inside that create these folders:
- binXX
- include
- libXX
- Copy
caffeine.h
into include - Copy
libcaffeine.dylib
into binXX - Copy
libcaffeined.a
(static lib) andlibcaffeined.dylib
into libXX - Copy
libcaffeine.a
(static lib) andlibcaffeine.dylib
into libXX - From
CMakeFiles/Export/libXX/cmake
folder copylibcaffeineTarget.cmake
,libcaffeineTarget-debug.cmake
,libcaffeineTarget-relwithdebinfo.cmake
into libXX/cmake - Copy libcaffeineConfig.cmake into libXX/cmake
- Copy libcaffeineConfigVersion.cmake into libXX/cmake
- 7z a libcaffeine-vX.Y-macos.7z libcaffeine-vX.Y-macos
- Team: Frontend / Desktop
- Product Owner: Viral Desai
- Engineer: Prateeksha Das
- Engineer: David Chen