Skip to content

Commit ae4f64a

Browse files
committed
Merge branch 'develop'
2 parents bcf7ec8 + 977fc9b commit ae4f64a

File tree

120 files changed

+18435
-3078
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+18435
-3078
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*.userprefs
1010
.buildvars.py
1111
.sconsign.dblite
12+
.vs/config/*
1213

1314
# Build results
1415
[Dd]ebug/

.travis.yml

+48-50
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,54 @@
1-
sudo: false
2-
language: csharp
3-
4-
compiler:
5-
- clang
6-
7-
cache:
8-
apt: true
9-
directories:
10-
- $HOME/FFmpegbin
11-
12-
addons:
13-
apt:
14-
sources:
15-
# Try to add up to date compilers
16-
- ubuntu-toolchain-r-test
17-
- llvm-toolchain-precise-3.6
18-
packages:
19-
- nasm
20-
- build-essential
21-
- cmake
22-
- libcppunit-dev
23-
- gcc-5
24-
- g++-5
25-
- clang-3.6
1+
language: generic
2+
# Build with docker to have an up-to-date version of ubuntu
3+
sudo: required
4+
services:
5+
- docker
6+
7+
notifications:
8+
email: false
9+
10+
branches:
11+
only:
12+
- master
13+
- develop
14+
15+
git:
16+
depth: 1
17+
18+
#cache:
19+
# directories:
20+
# - $HOME/docker
2621

2722
install:
28-
- nuget restore TS3AudioBot.sln
29-
- nuget install NUnit.Runners -OutputDirectory nunit
30-
31-
before_script:
32-
- export THREADS=$((`nproc` + 1))
33-
- echo "THREADS = $THREADS"
34-
- cd "$HOME"
35-
- if [ ! -f "$HOME/FFmpegbin/libavcodec/libavcodec.so" ]; then git clone --depth 1 --branch n3.0 https://github.com/FFmpeg/FFmpeg.git; fi
36-
- if [ ! -f "$HOME/FFmpegbin/libavcodec/libavcodec.so" ]; then mkdir -p FFmpegbin; cd FFmpegbin; fi
37-
- if [ ! -f "$HOME/FFmpegbin/libavcodec/libavcodec.so" ]; then $HOME/FFmpeg/configure --enable-shared; fi
38-
- if [ ! -f "$HOME/FFmpegbin/libavcodec/libavcodec.so" ]; then make -j $THREADS; fi
39-
40-
solution: TS3AudioBot.sln
23+
# Use the cached docker image if it is available
24+
- mkdir -p "$HOME/docker"
25+
- if [ -f "$HOME/docker/ts3audiobot.tar" ]; then
26+
docker import "$HOME/docker/ts3audiobot.tar" ts3audiobot:latest;
27+
else
28+
docker build -t ts3audiobot -f Dockerfile .;
29+
fi
30+
# docker save -o "$HOME/docker/ts3audiobot.tar" ts3audiobot;
31+
# fi
32+
4133
script:
42-
# Building the AudioBob (C++ stuff)
43-
- cd $TRAVIS_BUILD_DIR/TS3AudioBob
44-
- mkdir bin
45-
- cd bin
46-
- cmake .. -DAVCODEC_INCLUDE_DIRS="$HOME/FFmpeg" -DAVCODEC_LIBRARIES="$HOME/FFmpegbin/libavcodec/libavcodec.so" -DAVFILTER_INCLUDE_DIRS="$HOME/FFmpeg" -DAVFILTER_LIBRARIES="$HOME/FFmpegbin/libavfilter/libavfilter.so" -DAVFORMAT_INCLUDE_DIRS="$HOME/FFmpeg" -DAVFORMAT_LIBRARIES="$HOME/FFmpegbin/libavformat/libavformat.so" -DAVUTIL_INCLUDE_DIRS="$HOME/FFmpegbin" -DAVUTIL_LIBRARIES="$HOME/FFmpegbin/libavutil/libavutil.so" -DSWSCALE_INCLUDE_DIRS="$HOME/FFmpeg" -DSWSCALE_LIBRARIES="$HOME/FFmpegbin/libswscale/libswscale.so" -DSWRESAMPLE_INCLUDE_DIRS="$HOME/FFmpeg" -DSWRESAMPLE_LIBRARIES="$HOME/FFmpegbin/libswresample/libswresample.so" -DSWSCALE_INCLUDE_DIRS="$HOME/FFmpeg" -DSWSCALE_LIBRARIES="$HOME/FFmpegbin/libswscale/libswscale.so" -DBUILD_TESTS=1 -DBUILD_FUZZ=1 -DCMAKE_C_COMPILER=`which clang` -DCMAKE_CXX_COMPILER=`which clang++`
47-
- make VERBOSE=1 -j $THREADS
48-
- LD_LIBRARY_PATH="$HOME/FFmpegbin/libavcodec:$HOME/FFmpegbin/libavfilter:$HOME/FFmpegbin/libavformat:$HOME/FFmpegbin/libavutil:$HOME/FFmpegbin/libswresample:$HOME/FFmpegbin/libswscale" ./ts3audiobobtest
49-
50-
# Building the AudioBot (C# stuff)
51-
- cd "$TRAVIS_BUILD_DIR"
52-
- xbuild /p:Configuration=Release TS3AudioBot.sln
53-
- mono ./nunit/NUnit.ConsoleRunner.*.*.*/tools/nunit3-console.exe ./TS3ABotUnitTests/bin/Release/TS3ABotUnitTests.dll
34+
- docker run -v "$TRAVIS_BUILD_DIR:/build" ts3audiobot sh -c "
35+
export THREADS=\$((`nproc` + 1)) &&
36+
echo \"THREADS = \$THREADS\" &&
37+
38+
echo Building the AudioBob \(C++ stuff\) &&
39+
cd TS3AudioBob &&
40+
mkdir bin && cd bin &&
41+
cmake .. -DBUILD_TESTS=1 -DBUILD_FUZZ=1 &&
42+
make VERBOSE=1 -j \$THREADS &&
43+
./ts3audiobobtest &&
44+
cd ../.. &&
45+
46+
echo Building the AudioBot \(C# Stuff\) &&
47+
nuget restore TS3AudioBot.sln &&
48+
nuget install NUnit.Runners -OutputDirectory nunit &&
49+
xbuild /p:Configuration=Release TS3AudioBot.sln &&
50+
mono ./nunit/NUnit.ConsoleRunner.*.*.*/tools/nunit3-console.exe ./TS3ABotUnitTests/bin/Release/TS3ABotUnitTests.dll
51+
"
5452
5553
after_script:
5654
- cd $TRAVIS_BUILD_DIR

ClassDiagram.dia

2.04 KB
Binary file not shown.

ClassDiagram.svg

+430-277
Loading

Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ubuntu:xenial
2+
3+
# Get dependencies
4+
RUN apt-get update && apt-get -y install build-essential cmake libcppunit-dev \
5+
libavcodec-dev libavfilter-dev libavformat-dev libavresample-dev \
6+
libavutil-dev git mono-xbuild nuget mono-devel
7+
8+
RUN mkdir /build
9+
WORKDIR /build

PluginTests/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>

PluginTests/PluginA.cs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace PluginTests
8+
{
9+
class PluginA : IPlugin
10+
{
11+
public void Initialize(MainClass mc)
12+
{
13+
14+
}
15+
}
16+
}

PluginTests/PluginTests.csproj

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{DDBB1943-929D-43F6-A7E1-01903DD05D64}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>PluginTests</RootNamespace>
11+
<AssemblyName>PluginTests</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Xml.Linq" />
38+
<Reference Include="System.Data.DataSetExtensions" />
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.Data" />
41+
<Reference Include="System.Net.Http" />
42+
<Reference Include="System.Xml" />
43+
</ItemGroup>
44+
<ItemGroup>
45+
<Compile Include="PluginA.cs">
46+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
47+
</Compile>
48+
<Compile Include="Program.cs" />
49+
<Compile Include="Properties\AssemblyInfo.cs" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<None Include="App.config" />
53+
</ItemGroup>
54+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
55+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
56+
Other similar extension points exist, see Microsoft.Common.targets.
57+
<Target Name="BeforeBuild">
58+
</Target>
59+
<Target Name="AfterBuild">
60+
</Target>
61+
-->
62+
</Project>

PluginTests/Program.cs

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
using System;
2+
using System.CodeDom.Compiler;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Reflection;
6+
using System.Linq;
7+
8+
namespace PluginTests
9+
{
10+
class Program
11+
{
12+
static void Main(string[] args)
13+
{
14+
var mc = new MainClass();
15+
mc.LoadPlugin(new FileInfo("PluginA.cs"));
16+
}
17+
}
18+
19+
public class MainClass
20+
{
21+
public void Feature1() { }
22+
public void Feature2(int value) { int x = value + 10; var x2 = x.ToString().Split('1'); }
23+
public int Feature3() { return 42; }
24+
public MainClass Feature4() { return this; }
25+
26+
private static readonly FileInfo ts3File = new FileInfo(typeof(IPlugin).Assembly.Location);
27+
public AppDomain domain;
28+
29+
public PluginResponse LoadPlugin(FileInfo file)
30+
{
31+
try
32+
{
33+
if (file.Extension != ".cs" && file.Extension != ".dll" && file.Extension != ".exe")
34+
return PluginResponse.UnsupportedFile;
35+
36+
domain = AppDomain.CreateDomain(
37+
"Plugin_" + file.Name,
38+
AppDomain.CurrentDomain.Evidence,
39+
new AppDomainSetup
40+
{
41+
ShadowCopyFiles = "true",
42+
ShadowCopyDirectories = ts3File.Directory.FullName,
43+
ApplicationBase = ts3File.Directory.FullName,
44+
PrivateBinPath = "Plugin/..;Plugin",
45+
PrivateBinPathProbe = ""
46+
});
47+
domain.UnhandledException += (s, e) => { Console.WriteLine("Plugin unex: {0}", e.ExceptionObject); };
48+
49+
//domain.Load()
50+
51+
Assembly result;
52+
if (file.Extension == ".cs")
53+
result = PrepareSource(file);
54+
else if (file.Extension == ".dll" || file.Extension == ".exe")
55+
result = PrepareBinary(file);
56+
else throw new InvalidProgramException();
57+
58+
return PluginResponse.Ok;
59+
}
60+
catch (Exception ex)
61+
{
62+
Console.WriteLine("Possible plugin failed to load: ", ex);
63+
return PluginResponse.Crash;
64+
}
65+
}
66+
67+
private static CompilerParameters GenerateCompilerParameter()
68+
{
69+
var cp = new CompilerParameters();
70+
Assembly[] aarr = AppDomain.CurrentDomain.GetAssemblies();
71+
for (int i = 0; i < aarr.Length; i++)
72+
{
73+
if (aarr[i].IsDynamic) continue;
74+
cp.ReferencedAssemblies.Add(aarr[i].Location);
75+
}
76+
cp.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);
77+
78+
// set preferences
79+
cp.WarningLevel = 3;
80+
cp.CompilerOptions = "/target:library /optimize";
81+
cp.GenerateExecutable = false;
82+
cp.GenerateInMemory = true;
83+
return cp;
84+
}
85+
86+
private Assembly PrepareSource(FileInfo file)
87+
{
88+
var provider = CodeDomProvider.CreateProvider("CSharp");
89+
var cp = GenerateCompilerParameter();
90+
var result = provider.CompileAssemblyFromFile(cp, file.FullName);
91+
92+
if (result.Errors.Count > 0)
93+
{
94+
bool containsErrors = false;
95+
foreach (CompilerError error in result.Errors)
96+
{
97+
containsErrors |= !error.IsWarning;
98+
Console.WriteLine("Plugin_{0}: {1} L{2}/C{3}: {4}\n",
99+
file.Name,
100+
error.IsWarning ? "Warning" : "Error",
101+
error.Line,
102+
error.Column,
103+
error.ErrorText);
104+
}
105+
106+
if (containsErrors)
107+
return null;
108+
}
109+
110+
return result.CompiledAssembly;
111+
}
112+
113+
private Assembly PrepareBinary(FileInfo file)
114+
{
115+
return null;
116+
}
117+
}
118+
119+
public interface IPlugin
120+
{
121+
void Initialize(MainClass mc);
122+
}
123+
124+
public enum PluginResponse
125+
{
126+
Ok,
127+
UnsupportedFile,
128+
Crash,
129+
NoTypeMatch,
130+
TooManyPlugins,
131+
UnknownStatus,
132+
PluginNotFound,
133+
CompileError,
134+
}
135+
}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("PluginTests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("PluginTests")]
13+
[assembly: AssemblyCopyright("Copyright © 2016")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("ddbb1943-929d-43f6-a7e1-01903dd05d64")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)