Skip to content

Commit 2a908aa

Browse files
committed
Updating to v1.2.4
UI / Torrent Streaming - Adding Escape / Middle Mouse Click for Torrent File List and jumping from one to another (it will continue from the point it stopped - no re-downloading) UI - Adding Right Mouse Click for Pause/Play TorSwarm - Implementing Pause/Continue Functionality (in case of different files within the torrent) TorSwarm - Fixed an Issue with Include/Exlude Functionality (it was deleting the previous status of excluded files) Updating FFmpeg's swscale to latest (after prev commit that linesize/pitch for software texture was fixed) Former-commit-id: a57355a
1 parent b2a38ac commit 2a908aa

10 files changed

Lines changed: 101 additions & 23 deletions

File tree

11.5 KB
Binary file not shown.
9.5 KB
Binary file not shown.
512 Bytes
Binary file not shown.
512 Bytes
Binary file not shown.

MediaRouter/MediaRouter.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private void VideoScreamer()
267267
Log($"[VIDEO SCREAMER] No Frames, Restarting ...");
268268

269269
Thread.Sleep(150);
270-
if ( vFrames.Count > 0 ) continue;
270+
if ( isTorrent && vFrames.Count > 0 || vFrames.Count > VIDEO_MIX_QUEUE_SIZE) continue;
271271

272272
Thread restart = new Thread(() => {
273273
Seek((int) ((CurTime + decoder.vStreamInfo.frameAvgTicks *2)/10000));
@@ -833,19 +833,36 @@ public void Close()
833833
public void StopMediaStreamer() { if ( streamer != null ) { streamer.Stop(); streamer = null; } }
834834
public void SetMediaFile(string fileName)
835835
{
836+
if (openOrBuffer!= null) openOrBuffer.Abort();
837+
if (streamer != null && isTorrent) streamer.Pause();
838+
if (decoder != null) decoder.Pause();
839+
if (screamer != null) screamer.Abort();
840+
if (aScreamer != null) aScreamer.Abort();
841+
if (vScreamer != null) vScreamer.Abort();
842+
if (sScreamer != null) sScreamer.Abort();
843+
844+
isReady = false;
845+
status = Status.STOPPED;
846+
beforeSeeking = Status.STOPPED;
847+
decoder.HWAccel = HWAccel;
848+
849+
lock (aFrames) aFrames = new ConcurrentQueue<MediaFrame>();
850+
lock (vFrames) vFrames = new ConcurrentQueue<MediaFrame>();
851+
lock (sFrames) sFrames = new ConcurrentQueue<MediaFrame>();
852+
836853
if (openOrBuffer != null) { openOrBuffer.Abort(); Thread.Sleep(20); }
837854

838855
openOrBuffer = new Thread(() => {
839856

840857
// Open Decoder Buffer
841858
int ret = streamer.SetMediaFile(fileName);
842-
if (ret != 0) { status = Status.FAILED; OpenStreamSuccessClbk?.BeginInvoke(false, fileName, null, null); }
859+
if (ret != 0) { status = Status.FAILED; OpenStreamSuccessClbk?.BeginInvoke(false, fileName, null, null); return; }
843860

844861
// Open Decoder
845862
ret = decoder.Open(null, streamer.DecoderRequests, streamer.fileSize);
846-
if (ret != 0) { status = Status.FAILED; OpenStreamSuccessClbk?.BeginInvoke(false, fileName, null, null); }
863+
if (ret != 0) { status = Status.FAILED; OpenStreamSuccessClbk?.BeginInvoke(false, fileName, null, null); return; }
847864

848-
if (!decoder.isReady) { status = Status.FAILED; OpenStreamSuccessClbk?.BeginInvoke(false, fileName, null, null); }
865+
if (!decoder.isReady) { status = Status.FAILED; OpenStreamSuccessClbk?.BeginInvoke(false, fileName, null, null); return; }
849866

850867
InitializeEnv();
851868
OpenStreamSuccessClbk?.BeginInvoke(true, fileName, null, null);

MediaRouter/MediaStreamer.cs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,14 @@ public int Open(string url, StreamType streamType = StreamType.TORRENT, bool isM
143143
}
144144
else if ( streamType == StreamType.TORRENT )
145145
{
146+
if ( tsStream != null ) tsStream.Dispose();
147+
146148
TorSwarm.OptionsStruct opt = TorSwarm.GetDefaultsOptions();
147149
opt.FocusPointCompleted = FocusPointCompleted;
148150
opt.TorrentCallback = MetadataReceived;
149151
opt.PieceTimeout = 4300;
152+
opt.LogStats = true;
153+
opt.Verbosity = 1;
150154

151155
try
152156
{
@@ -174,15 +178,25 @@ private void MetadataReceived(Torrent torrent)
174178
public int SetMediaFile(string fileName)
175179
{
176180
Log($"File Selected {fileName}");
177-
181+
178182
if ( streamType == StreamType.FILE )
179183
{
180184
int ret = decoder.Open(null, DecoderRequestsBuffer, fileSize);
181185
return ret;
182186
}
183187
else if ( streamType == StreamType.TORRENT )
184188
{
185-
tsStream.IncludeFiles(new List<string>() { fileName });
189+
Pause();
190+
191+
aDone = false; vDone = false; sDone = false;
192+
193+
lock (localFocusPoints)
194+
{
195+
foreach (KeyValuePair<long, Tuple<long, int>> curLFPKV in localFocusPoints)
196+
tsStream.DeleteFocusPoint(curLFPKV.Key);
197+
198+
localFocusPoints.Clear();
199+
}
186200

187201
fileIndex = torrent.file.paths.IndexOf(fileName);
188202
fileSize = torrent.file.lengths[fileIndex];
@@ -191,6 +205,9 @@ public int SetMediaFile(string fileName)
191205
for (int i=0; i<fileIndex; i++)
192206
fileDistance += torrent.file.lengths[i];
193207

208+
if (!torrent.data.files[fileIndex].FileCreated) tsStream.IncludeFiles(new List<string>() { fileName });
209+
210+
if ( !torrent.data.files[fileIndex].FileCreated && !tsStream.isRunning ) tsStream.Start();
194211
// Decoder - Opening Format Contexts (cancellation?) -> DecoderRequests Feed with null?
195212
Log($"[BB OPENING 1]");
196213
int ret = decoder.Open(null, DecoderRequestsBuffer, fileSize);
@@ -224,9 +241,10 @@ private void BufferingDone(AVMediaType mType)
224241
// Starts Internal Decoders for Seekings & Buffering
225242
public void SeekSubs(int ms)
226243
{
227-
if ( !decoder.isReady || !decoder.hasSubs || IsSubsExternal ) return;
228244
if ( streamType == StreamType.TORRENT && torrent != null && torrent.data.files[fileIndex].FileCreated ) { decoder.BufferingSubsDone?.BeginInvoke(null, null); return; }
229245

246+
if ( !decoder.isReady || !decoder.hasSubs || IsSubsExternal ) return;
247+
230248
try
231249
{
232250
if (sDecoder != null) sDecoder.Abort();
@@ -248,9 +266,10 @@ public void SeekSubs(int ms)
248266
}
249267
public void SeekAudio(int ms)
250268
{
251-
if ( !decoder.isReady || !decoder.hasAudio) return;
252269
if ( streamType == StreamType.TORRENT && torrent != null && torrent.data.files[fileIndex].FileCreated ) { decoder.BufferingAudioDone?.BeginInvoke(null, null); return; }
253270

271+
if ( !decoder.isReady || !decoder.hasAudio) return;
272+
254273
try
255274
{
256275
if (aDecoder != null) aDecoder.Abort();

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ A sample GUI has been created to demonstrate Media Router's functionality. It wo
3636
| Keys | Action |
3737
| :-------------: |:-------------: |
3838
| Drag & Drop | Open |
39-
| P or Space | Pause / Play |
39+
| P / Space / Right Click| Pause / Play |
40+
| Left / Right Arrows | Seeking |
4041
| S | Stop |
4142
| R | Keep Ratio |
42-
| F or Escape | Fullscreen |
43-
| Left / Right Arrows | Seeking |
43+
| F | Full Screen / Normal Screen|
44+
| Esc / Middle Click | Back to Torrent File List |
4445
| Up / Down Arrows | Volume Adjustment |
4546
| [ / ] | Audio Adjustment |
4647
| ; / ' | Subtitles Adjustment |
@@ -49,6 +50,23 @@ A sample GUI has been created to demonstrate Media Router's functionality. It wo
4950
<br/>
5051

5152
## Versioning | Changes
53+
#### v1.2.4 - 13/6/2020
54+
>__Additions__
55+
56+
* UI / Torrent Streaming - Adding Escape / Middle Mouse Click for Torrent File List and jumping from one to another (it will continue from the point it stopped - no re-downloading)
57+
* UI - Adding Right Mouse Click for Pause/Play
58+
* TorSwarm - Implementing Pause/Continue Functionality (in case of different files within the torrent)
59+
60+
>__Issues__
61+
62+
* One Frame Before Issue Fixed (by flushing the FFmpeg's D3D11Device)
63+
* Full Screen Aspect Ratio Issue Fixed (in cases display.Width / aspectRatio > display.Height)
64+
* Linesize for Software Texture Fixed (adding also latest FFmpeg's swscale now)
65+
* Crashing Issues during Opening (decoder.Stop was seeking at 0 / replaced it with Close - Pause)
66+
* After seeking was always keep playing on Torrent Streaming (fixed by remembering previous status)
67+
* TorSwarm - Fixed an Issue with Include/Exlude Functionality (it was deleting the previous status of excluded files)
68+
69+
5270
#### v1.2.3 - 9/6/2020
5371
>__Additions__
5472

UI Example/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyDescription("PartyTime")]
1212
[assembly: AssemblyCompany("PartyTime")]
13-
[assembly: AssemblyCopyright("Copyright © 2019")]
13+
[assembly: AssemblyCopyright("Copyright © 2020")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.2.0.0")]
36-
[assembly: AssemblyFileVersion("1.2.0.0")]
35+
[assembly: AssemblyVersion("1.2.4.0")]
36+
[assembly: AssemblyFileVersion("1.2.4.0")]

UI Example/UserInterface.cs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,9 @@ private void Open(string url)
527527

528528
screenPlayHW.Visible = player.iSHWAccelSuccess;
529529

530+
control.lstMediaFiles.Items.Clear();
531+
control.lstMediaFiles.Items.Add(url);
532+
530533
UpdateInfoText($"Opening {Path.GetFileName(url)} Success");
531534
Play();
532535
}
@@ -641,9 +644,10 @@ private void UnIdle()
641644
// Processes Streaming
642645
public void OpenTorrentSuccess(bool success)
643646
{
644-
Log("Player " + player.isOpened);
645-
if (player.isFailed) { UpdateInfoText($"Opening Torrent Failed"); Log("Error opening"); return; }
646-
UpdateInfoText($"Opening Torrent Success");
647+
if (player.isFailed || !success)
648+
UpdateInfoText($"Opening Torrent Failed");
649+
else
650+
UpdateInfoText($"Opening Torrent Success");
647651
}
648652
public void MediaFilesReceived(List<string> mediaFiles, List<long> mediaFilesSizes)
649653
{
@@ -901,7 +905,10 @@ private void Display_KeyPress(object sender, KeyPressEventArgs e)
901905
break;
902906

903907
case (char)Keys.Escape:
904-
NormalScreen();
908+
if (control.lstMediaFiles.Visible)
909+
control.lstMediaFiles.Visible = false;
910+
else if (!control.lstMediaFiles.Visible)
911+
{ control.lstMediaFiles.Visible = true; FixLstMediaFiles(); }
905912
break;
906913
}
907914
}
@@ -934,7 +941,18 @@ private void Display_DragDrop(object sender, DragEventArgs e)
934941
private void Display_MouseDown(object sender, MouseEventArgs e) { display2.TargetElapsedTime = TimeSpan.FromSeconds(1.0f / 50.0f); if (e.Button == MouseButtons.Left) { displayMLDown = true; displayMLDownPos = e.Location; } }
935942
private void Display_MouseUp(object sender, MouseEventArgs e) { display2.TargetElapsedTime = TimeSpan.FromSeconds(1.0f / 10.0f); if (e.Button == MouseButtons.Left) { displayMLDown = false; resizing = false; displayMoveSideCur = 0; FixFrmControl(); UnIdle(); } }
936943
private void Display_MouseClickDbl(object sender, MouseEventArgs e) { if (e.Clicks >= 2 && e.Button == MouseButtons.Left) FullScreenToggle(); }
937-
private void Display_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) if (player.isPlaying) { player.Pause(); audioPlayer.ResetClbk(); } else { player.Play(); } }
944+
private void Display_MouseClick(object sender, MouseEventArgs e)
945+
{
946+
if (e.Button == MouseButtons.Right) if (player.isPlaying) { player.Pause(); audioPlayer.ResetClbk(); } else { player.Play(); }
947+
948+
else if ( e.Button == MouseButtons.Middle )
949+
{
950+
if (control.lstMediaFiles.Visible)
951+
control.lstMediaFiles.Visible = false;
952+
else
953+
{ control.lstMediaFiles.Visible = true; FixLstMediaFiles(); }
954+
}
955+
}
938956
private void Display_MouseMove(object sender, MouseEventArgs e)
939957
{
940958
if (displayMMoveLastPos == e.Location) return;
@@ -1322,18 +1340,22 @@ private void VolBar_ValueChanged(object sender, EventArgs e)
13221340
// UI Events [CONTROL LSTMEDIAFILES]
13231341
private void lstMediaFiles_MouseClickDbl(object sender, MouseEventArgs e)
13241342
{
1343+
if ( !player.isTorrent ) { control.lstMediaFiles.Visible = false; display.Focus(); return; }
13251344
if ( control.lstMediaFiles.SelectedItem == null ) return;
13261345

13271346
SetMediaFile(control.lstMediaFiles.SelectedItem.ToString());
1347+
display.Focus();
13281348
}
13291349
private void lstMediaFiles_KeyPress(object sender, KeyPressEventArgs e)
13301350
{
13311351
lastUserActionTicks = DateTime.UtcNow.Ticks;
13321352

1333-
if ( e.KeyChar != (char)13 ) return;
1353+
if ( e.KeyChar != (char)13 ) { Display_KeyPress(sender, e); return; }
1354+
if ( !player.isTorrent ) { control.lstMediaFiles.Visible = false; display.Focus(); return; }
13341355
if ( control.lstMediaFiles.SelectedItem == null ) return;
13351356

13361357
SetMediaFile(control.lstMediaFiles.SelectedItem.ToString());
1358+
display.Focus();
13371359
}
13381360
private void lstMediaFiles_MouseMove(object sender, MouseEventArgs e) { lastUserActionTicks = DateTime.UtcNow.Ticks; }
13391361

@@ -1433,6 +1455,8 @@ private void FixLstMediaFiles()
14331455
control.lstMediaFiles.Width = Math.Min(850, display.Width - 200);
14341456
control.lstMediaFiles.Height = Math.Min(550, display.Height - 200);
14351457
control.lstMediaFiles.Location = new Point((control.Width- control.lstMediaFiles.Width) / 2, (control.Height- control.lstMediaFiles.Height) / 2);
1458+
1459+
control.lstMediaFiles.Focus();
14361460
}
14371461

14381462
// Logging

UI Example/frmControl.Designer.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)