Skip to content

Commit

Permalink
Добавлен OpenGL Render и небольшая модификация декодирования видео.
Browse files Browse the repository at this point in the history
  • Loading branch information
konvikkor committed Jan 3, 2019
1 parent 8dd280b commit eb625b8
Show file tree
Hide file tree
Showing 9 changed files with 845 additions and 202 deletions.
3 changes: 2 additions & 1 deletion TestVideo.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ uses
uVideoMain in 'uVideoMain.pas',
uMediaDisplay in 'uMediaDisplay.pas',
uMediaConstant in 'uMediaConstant.pas',
uVideoThread in 'uVideoThread.pas';
uVideoThread in 'uVideoThread.pas',
uMediaReader in 'uMediaReader.pas';

{$R *.res}

Expand Down
1 change: 1 addition & 0 deletions TestVideo.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<DCCReference Include="uMediaDisplay.pas"/>
<DCCReference Include="uMediaConstant.pas"/>
<DCCReference Include="uVideoThread.pas"/>
<DCCReference Include="uMediaReader.pas"/>
<None Include="ModelSupport_TestVideo\default.txaPackage"/>
<None Include="ModelSupport_TestVideo\default.txvpck"/>
<None Include="ModelSupport_TestVideo\uVideoMain\default.txvpck"/>
Expand Down
25 changes: 20 additions & 5 deletions uMediaConstant.pas
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ interface
//TOnReadAudioPacked = Function (Sender:TObject;var Pack:Pointer):Integer of object;
TOnRenderVideoFrame = procedure (w,h:SInt32;Data:Array of PByte;linesize: Array of Integer; pix_fmt:TAVPixelFormat) of object;
TOnIsPlayed = Procedure (Sender:TObject;var Play:Boolean)of object;
TOnFlushBuffer = procedure (Sender:TObject; var Item:Pointer) of object;

TMediaBufferInfo = packed Record
AVStream : PAVStream;
Expand All @@ -56,6 +57,7 @@ TMediaBuffer = class
private
CS:TCriticalSection;
FLastReadItem, FLastWriteItem:Cardinal;
FOnFlushBuffer: TOnFlushBuffer;
protected
FBuffer:TArray<Pointer>;
public
Expand All @@ -67,6 +69,8 @@ TMediaBuffer = class
Function GetSize:Cardinal;
Property LastReadItem:Cardinal read FLastReadItem;
property LastWriteItem:Cardinal read FLastWriteItem;
Property OnFlushBuffer:TOnFlushBuffer read FOnFlushBuffer write FOnFlushBuffer;
Procedure FlushBuffer;
end;

implementation
Expand All @@ -89,6 +93,17 @@ destructor TMediaBuffer.Destroy;
FreeAndNil(CS);
end;

procedure TMediaBuffer.FlushBuffer;
var i:Integer;
begin
for I := 0 to High(FBuffer) do begin
if FBuffer[i] <> nil then begin
FOnFlushBuffer(Self,FBuffer[i]);
if FBuffer[i] <> nil then FBuffer[i]:=nil;
end;
end;
end;

function TMediaBuffer.GetCount: Cardinal;
begin
//if Assigned(CS) then CS.Enter;
Expand All @@ -107,15 +122,15 @@ function TMediaBuffer.GetSize: Cardinal;
begin
//if Assigned(CS) then CS.Enter;
try
Result:=High(FBuffer);
Result:=High(FBuffer)-1;
finally
//if Assigned(CS) then CS.Leave;
end;
end;

function TMediaBuffer.ReadData(var Item: Pointer): Cardinal;
begin
if Assigned(CS) then CS.Enter;
//if Assigned(CS) then CS.Enter;
try
Result:=FLastReadItem;
Item:=FBuffer[FLastReadItem];
Expand All @@ -124,13 +139,13 @@ function TMediaBuffer.ReadData(var Item: Pointer): Cardinal;
inc(FLastReadItem);
if FLastReadItem > High(FBuffer) then FLastReadItem:=Low(FBuffer);
finally
if Assigned(CS) then CS.Leave;
//if Assigned(CS) then CS.Leave;
end;
end;

function TMediaBuffer.WriteData(var Item: Pointer): Cardinal;
begin
if Assigned(CS) then CS.Enter;
//if Assigned(CS) then CS.Enter;
try
Result:=FLastWriteItem;
if FBuffer[FLastWriteItem] <> nil then begin
Expand All @@ -141,7 +156,7 @@ function TMediaBuffer.WriteData(var Item: Pointer): Cardinal;
inc(FLastWriteItem);
if FLastWriteItem > High(FBuffer) then FLastWriteItem:=Low(FBuffer);
finally
if Assigned(CS) then CS.Leave;
//if Assigned(CS) then CS.Leave;
end;
end;

Expand Down
Loading

0 comments on commit eb625b8

Please sign in to comment.