Skip to content

Commit 477e052

Browse files
committed
Added Pinvoke wrapper and created cross platform lib
1 parent 7be2102 commit 477e052

Some content is hidden

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

64 files changed

+5480
-245
lines changed

.editorconfig

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[*.cs]
2+
3+
# CA1416: Validate platform compatibility
4+
dotnet_diagnostic.CA1416.severity = none
5+
csharp_indent_labels = one_less_than_current
6+
csharp_using_directive_placement = outside_namespace:silent
7+
csharp_prefer_simple_using_statement = true:suggestion
8+
csharp_prefer_braces = true:silent
9+
csharp_style_namespace_declarations = block_scoped:silent
10+
csharp_style_prefer_method_group_conversion = true:silent
11+
csharp_style_prefer_top_level_statements = true:silent
12+
csharp_style_prefer_primary_constructors = true:suggestion
13+
csharp_style_expression_bodied_methods = false:silent
14+
csharp_style_expression_bodied_constructors = false:silent
15+
csharp_style_expression_bodied_operators = false:silent
16+
csharp_style_expression_bodied_properties = true:silent
17+
18+
[*.{cs,vb}]
19+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
20+
tab_width = 4
21+
indent_size = 4
22+
end_of_line = crlf
23+
[*.{cs,vb}]
24+
#### Naming styles ####
25+
26+
# Naming rules
27+
28+
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
29+
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
30+
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
31+
32+
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
33+
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
34+
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
35+
36+
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
37+
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
38+
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
39+
40+
# Symbol specifications
41+
42+
dotnet_naming_symbols.interface.applicable_kinds = interface
43+
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
44+
dotnet_naming_symbols.interface.required_modifiers =
45+
46+
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
47+
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
48+
dotnet_naming_symbols.types.required_modifiers =
49+
50+
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
51+
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
52+
dotnet_naming_symbols.non_field_members.required_modifiers =
53+
54+
# Naming styles
55+
56+
dotnet_naming_style.begins_with_i.required_prefix = I
57+
dotnet_naming_style.begins_with_i.required_suffix =
58+
dotnet_naming_style.begins_with_i.word_separator =
59+
dotnet_naming_style.begins_with_i.capitalization = pascal_case
60+
61+
dotnet_naming_style.pascal_case.required_prefix =
62+
dotnet_naming_style.pascal_case.required_suffix =
63+
dotnet_naming_style.pascal_case.word_separator =
64+
dotnet_naming_style.pascal_case.capitalization = pascal_case
65+
66+
dotnet_naming_style.pascal_case.required_prefix =
67+
dotnet_naming_style.pascal_case.required_suffix =
68+
dotnet_naming_style.pascal_case.word_separator =
69+
dotnet_naming_style.pascal_case.capitalization = pascal_case

EncoderTest/Program.cs

Lines changed: 0 additions & 83 deletions
This file was deleted.
36.5 KB
Binary file not shown.
36.5 KB
Binary file not shown.

NetCoreTest/NetCoreTest.csproj renamed to Examples/H264SharpCLIdotNET/H264SharpCLIdotNET.csproj

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,28 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net6.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
68
</PropertyGroup>
79

810
<ItemGroup>
9-
<None Remove="ocean.jpg" />
10-
</ItemGroup>
11-
12-
<ItemGroup>
13-
<Content Include="ocean.jpg">
14-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
15-
</Content>
16-
</ItemGroup>
17-
18-
<ItemGroup>
19-
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
11+
<PackageReference Include="System.Drawing.Common" Version="8.0.1" />
2012
</ItemGroup>
2113

2214
<ItemGroup>
2315
<Reference Include="H264SharpNetCore64">
24-
<HintPath>..\x64\Release\H264SharpNetCore64.dll</HintPath>
16+
<HintPath>..\..\x64\Release\H264SharpNetCore64.dll</HintPath>
2517
</Reference>
2618
</ItemGroup>
2719

2820
<ItemGroup>
29-
<None Update="openh264-2.1.1-win64.dll">
21+
<None Update="Converter32.dll">
22+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
23+
</None>
24+
<None Update="Converter64.dll">
25+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
26+
</None>
27+
<None Update="ocean.jpg">
3028
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3129
</None>
3230
<None Update="openh264-2.3.1-win32.dll">
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Drawing;
7+
using System.Diagnostics;
8+
using System.Threading;
9+
using System.Drawing.Imaging;
10+
using H264Sharp;
11+
12+
namespace EncoderTest
13+
{
14+
internal class Program
15+
{
16+
static H264Sharp.Encoder encoder;
17+
static H264Sharp.Decoder decoder;
18+
static void Main(string[] args)
19+
{
20+
decoder = new H264Sharp.Decoder();
21+
encoder = new H264Sharp.Encoder();
22+
23+
var img = System.Drawing.Image.FromFile("ocean.jpg");
24+
int w = img.Width;
25+
int h = img.Height;
26+
var bmp = new Bitmap(img);
27+
28+
Console.WriteLine($"Image Loaded with Width{w}, Height:{h}");
29+
30+
encoder.Initialize(w, h, bps: 200_000_000, fps: 30, H264Sharp.Encoder.ConfigType.CameraBasic);
31+
32+
// Emulating video frames
33+
Stopwatch sw = Stopwatch.StartNew();
34+
for (int i = 0; i < 100; i++)
35+
{
36+
if (encoder.Encode(bmp, out EncodedFrame[] frames))
37+
{
38+
foreach (var frame in frames)
39+
{
40+
//frame.CopyTo(bb,0);
41+
42+
if (decoder.Decode(frame.Data, frame.Length, noDelay: true, out DecodingState ds, out Bitmap b))
43+
{
44+
b.Dispose();
45+
// bmp.Save("t.bmp");
46+
}
47+
}
48+
49+
}
50+
}
51+
Console.WriteLine("\n Time: " + sw.ElapsedMilliseconds);
52+
53+
Console.ReadLine();
54+
}
55+
56+
57+
}
58+
}
File renamed without changes.
File renamed without changes.
60.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)