Skip to content

Commit

Permalink
Merge pull request #2 from vignetteapp/fix-code-before-docs
Browse files Browse the repository at this point in the history
Fix code before making the docs
  • Loading branch information
sr229 authored Dec 5, 2021
2 parents 04a29eb + 1f362a2 commit a410345
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 10 deletions.
5 changes: 3 additions & 2 deletions SeeShark.Example.Ascii/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This file is part of SeeShark.
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details.

using System;
using System.Diagnostics;
using System.Text;
using static SeeShark.FFmpeg.FFmpegManager;
Expand Down Expand Up @@ -72,7 +73,7 @@ static void Main(string[] args)

/// Attach our <see cref="OnNewFrame"/> method to the camera's frame event handler,
/// so that we can process every coming frame the way we want.
karen.NewFrameHandler += OnNewFrame;
karen.OnFrame += OnFrameEventHandler;

Console.WriteLine($"Camera chosen: {karen.Info}");
Console.WriteLine("Press Space or P to play/pause the camera.");
Expand Down Expand Up @@ -115,7 +116,7 @@ static void Main(string[] args)
/// Each time it is triggered, it will draw a new ASCII frame on the screen
/// and update the terminal window title.
/// </summary>
public static void OnNewFrame(object? _sender, FrameEventArgs e)
public static void OnFrameEventHandler(object? _sender, FrameEventArgs e)
{
var frame = e.Frame;
if (converter == null || Console.WindowWidth != converter.SrcWidth ||
Expand Down
2 changes: 1 addition & 1 deletion SeeShark.Example.Ascii/SeeShark.Example.Ascii.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
12 changes: 6 additions & 6 deletions SeeShark/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// This file is part of SeeShark.
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details.

using System;
using System.Threading;
using SeeShark.FFmpeg;

namespace SeeShark
Expand All @@ -11,26 +13,24 @@ public class Camera : IDisposable
private Thread? decodingThread;
private readonly CameraStreamDecoder decoder;

public CameraInfo Info { get; private set; }
public CameraInfo Info { get; }
public bool IsPlaying { get; private set; }
public bool IsDisposed { get; private set; }

public event EventHandler<FrameEventArgs>? NewFrameHandler;
public event EventHandler<FrameEventArgs>? OnFrame;

public Camera(CameraInfo info, DeviceInputFormat inputFormat)
{
Info = info;
decoder = new CameraStreamDecoder(info.Path, inputFormat);
}

protected void OnNewFrame(FrameEventArgs e) => NewFrameHandler?.Invoke(this, e);

protected void DecodeLoop()
{
DecodeStatus status;
while ((status = decoder.TryDecodeNextFrame(out var frame)) != DecodeStatus.EndOfStream)
{
OnNewFrame(new FrameEventArgs(frame, status));
OnFrame?.Invoke(this, new FrameEventArgs(frame, status));

if (!IsPlaying)
break;
Expand All @@ -52,7 +52,7 @@ public void StartCapture()
return;

IsPlaying = true;
decodingThread = new Thread(new ThreadStart(DecodeLoop));
decodingThread = new Thread(DecodeLoop);
decodingThread.Start();
}

Expand Down
2 changes: 2 additions & 0 deletions SeeShark/CameraInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// This file is part of SeeShark.
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details.

using System;

namespace SeeShark
{
/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions SeeShark/CameraManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
// This file is part of SeeShark.
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details.

using System;
using System.Collections.Immutable;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using DirectShowLib;
using FFmpeg.AutoGen;
using SeeShark.FFmpeg;
Expand Down
2 changes: 2 additions & 0 deletions SeeShark/FFmpeg/DeviceInputFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// This file is part of SeeShark.
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details.

using System;

namespace SeeShark.FFmpeg
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions SeeShark/FFmpeg/FFmpegHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This file is part of SeeShark.
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details.

using System;
using System.Runtime.InteropServices;
using FFmpeg.AutoGen;

Expand Down
4 changes: 4 additions & 0 deletions SeeShark/FFmpeg/FFmpegManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// This file is part of SeeShark.
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using FFmpeg.AutoGen;
using LF = SeeShark.FFmpeg.LibraryFlags;
Expand Down
3 changes: 3 additions & 0 deletions SeeShark/FFmpeg/LibraryFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// This file is part of SeeShark.
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details.

using System;
using System.Collections.Generic;

namespace SeeShark.FFmpeg
{
[Flags]
Expand Down
3 changes: 3 additions & 0 deletions SeeShark/FFmpeg/VideoStreamDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// This file is part of SeeShark.
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details.

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
using FFmpeg.AutoGen;
using static SeeShark.FFmpeg.FFmpegManager;

Expand Down
1 change: 1 addition & 0 deletions SeeShark/Frame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This file is part of SeeShark.
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details.

using System;
using FFmpeg.AutoGen;

namespace SeeShark
Expand Down
1 change: 1 addition & 0 deletions SeeShark/FrameConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This file is part of SeeShark.
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details.

using System;
using System.Runtime.InteropServices;
using FFmpeg.AutoGen;

Expand Down
1 change: 1 addition & 0 deletions SeeShark/FrameEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This file is part of SeeShark.
// SeeShark is licensed under the BSD 3-Clause License. See LICENSE for details.

using System;
using SeeShark.FFmpeg;

namespace SeeShark
Expand Down
2 changes: 1 addition & 1 deletion SeeShark/SeeShark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AssemblyName>SeeShark</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<ImplicitUsings>disable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down

0 comments on commit a410345

Please sign in to comment.