ufrmMHWRadio.pas ( File view )

  • By sathex 2016-03-20
  • View(s):0
  • Download(s):0
  • Point(s): 1
			unit ufrmMHWRadio;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,UMDDefs,UTS184ToBitFilter, ComCtrls,Unit_CRC32,
  ExtCtrls, Grids,IniFiles,uDecode123,UnitTimer, jpeg,Math,
  uUPClickSplitter,UnitMDInterface,UMD_Impl,uDVBTablesHolder;

type eMHWRADIO_FILE_FORMAT=(eMHWRADIO_FILE_MPA,eMHWRADIO_FILE_MP2);

type TRSongInfo=record
    Channel: BYTE;
    Title: String;
    Artist: String;
    Album: String;
    Year: String;
    Compositors: String;
    MHWReference: String;
    Controller: String;
    CRC32: DWORD;
end;

Type TID3V100=packed record
    TAG: array [0..2] of char;
    Song: array [0..29] of char;
    Artist: array [0..29] of char;
    Album: array [0..29] of char;
    Year: array [0..3] of char;
    Comment: array [0..29] of char;
    Genre: BYTE;
end;

Type TSimpleWAV=packed record
    RIFF: array [0..3] of char;
    RIFFSize: DWORD;
    Sign: array [0..3] of char;
    fmt: array [0..3] of char;
    fmtSize: DWORD;
    FormatTAG: WORD;
    Channels: WORD;
    SamplesPerSec: DWORD;
    BypesPerSec: DWORD;
    BlockAlign: WORD;
    BitsPerSample: WORD;
    Data: array [0..3] of char;
    SizeData: DWORD;
end;

type
  TfrmMHWRadio = class(TForm)
    chkRadioOn: TCheckBox;
    lblGroup64: TLabel;
    lblGroup66: TLabel;
    lblGroup68: TLabel;
    imgBlueNote: TImage;
    Panel1: TPanel;
    lvNow: TListView;
    spltSplitterMain: TUPClickSplitter;
    butRecord: TButton;
    Label1: TLabel;
    Panel2: TPanel;
    grdMapping: TStringGrid;
    butChannelUp: TButton;
    butChannelDown: TButton;
    butStop: TButton;
    StatusBar1: TStatusBar;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure chkRadioOnClick(Sender: TObject);
    procedure imgBlueNoteClick(Sender: TObject);
    procedure butRecordClick(Sender: TObject);
    procedure butChannelUpClick(Sender: TObject);
    procedure butChannelDownClick(Sender: TObject);
    procedure lvNowSelectItem(Sender: TObject; Item: TListItem;
      Selected: Boolean);
    procedure butStopClick(Sender: TObject);
  protected
  private
    {
 Private declarations 
}
    mvarDefaultDock: TWinControl;
    mvarActive: Boolean;
    mvarInformation: array [0..17] of TRSongInfo;
    mvarSaveRadioSettings: Boolean;
    mvarRecordPath: string;
    mvarFileAudioMode: eMHWRADIO_FILE_FORMAT;
    mvarTablesBuffer: TDVBTablesHolder;
    mvarUseTAGID3V100: Boolean;
//    procedure UpdateVU(VUNum: integer;Volume: integer);
    function ComputeAudioCut(Channel: integer;Buffer: PBYTEARRAY; Len: DWORD): DWORD;
    function ValidateFileName(FileName: String): string;
    function ValidatePath(PathName: String): string;
    procedure UpdateStructures(Group: Integer;Info: TStringList);
    function ParseRadioInfoPacket(Buffer: TDVBTablesHolder): TStringList;
{
$hints off
}
    function GetHexFromArray(P: PBYTEARRAY;Start: DWORD; Len: DWORD; Separator: string): string;
{
$Hints on
}
    function getRadioEnabled: Boolean;
    procedure setRadioEnabled(const Value: Boolean);
    procedure SaveRadioSettings();
    Procedure ClearMPGLIB_DLLFiles();
  public
    {
 Public declarations 
}
    MD: TMultiDec;
    property DefaultDock: TWinControl read mvarDefaultDock write mvarDefaultDock;
    property EnableRadio: Boolean read getRadioEnabled write setRadioEnabled;
    property RecordPath: string read mvarRecordPath write mvarRecordPath;
    property FileFormat: eMHWRADIO_FILE_FORMAT read mvarFileAudioMode write mvarFileAudioMode;
    procedure AddPIDChannel(PID: WORD;Description: String);
    procedure ReloadSettings();

    procedure OnStart(MDInstance:THANDLE;MDWnd: HWND;Log_Set: Boolean;
                      DLL_ID: integer;My_Hot_Key: PChar;Api_Version: PChar;
                      Keep_me_running: PINTEGER);
    procedure OnExit (MDInstance: THANDLE;MDWnd: HWND;Log_Set: Boolean);
    procedure OnFilterClose(FilterOffset: DWORD);
    procedure OnChannelChange(CurrentProgramm: TMDProgram82 );
    procedure OnFilterData(FilterHandle: integer; FilterData: PBYTEARRAY; DataLength: integer);
  end;

var
  frmMHWRadio: TfrmMHWRadio=nil;

implementation

uses Types, DateUtils;

{
$R *.dfm
}
const MHWRADIO='MHWRADIO-HILOMUSICAL';

type TRFilters=record
    DescriptionsHandle: integer;
    Descriptions184Filter: TTS184ToBitFilter;
    AudioHandles: array [0..15] of integer;
    AudioBuffersPES: array [0..15] of TTS184ToBitFilter;
    AudioDecoders: array [0..15] of TDecode123;
    AudioPath: array [0..15] of String;
    AudioFileHandle: array [0..15] of TFileStream;
    AudioTimer: Array [0..15] of TFineTimer;
    AudioFileWrote: Array [0..15] of DWORD;
    AudioCut: Array [0..15] of DWORD;
    SongInfo: array [0..15] of TRSongInfo;
    IsFirstSong: array [0..15] of Boolean;
end;

var
    RFilters: TRFilters;
    iFilterTotalData: int64;

procedure TfrmMHWRadio.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
    if Assigned(mvarDefaultDock) Then begin
        CanClose:=false;
        Self.ManualDock(mvarDefaultDock,nil,alClient);
    end;
end;

procedure TfrmMHWRadio.FormCreate(Sender: TObject);
var
    TP: TMDProgram82;
    j: integer;
begin
  inherited;
    mvarDefaultDock:=nil;
    mvarTablesBuffer:=nil;
    mvarUseTAGID3V100:=true;
//    Self.Enabled:=false;
    mvarActive:=false;
    iFilterTotalData:=0;
    MD.DockedWindow:=false;
    RFilters.DescriptionsHandle:=-1;
    if not IsLibrary Then begin
        OnChannelChange(TP);
    end;
    grdMapping.DefaultRowHeight:=Self.Canvas.TextHeight('M')+4;
    grdMapping.Cells[0,0]:='Channel';
    grdMapping.Cells[1,0]:='PID';
    grdMapping.Cells[2,0]:='Description';
    grdMapping.ColWidths[0]:=60;
    grdMapping.ColWidths[1]:=40;
    grdMapping.ColWidths[2]:=200;

    for j := 0 to 15 do begin
        RFilters.AudioHandles[j]:=-1;
        RFilters.AudioBuffersPES[j]:=nil;
        RFilters.AudioDecoders[j]:=nil;
        RFilters.AudioPath[j]:='';
        RFilters.AudioFileHandle[j]:=nil;
        RFilters.AudioTimer[j]:=nil;
        RFilters.AudioFileWrote[j]:=0;
        RFilters.AudioCut[j]:=0;
    end;

    setRadioEnabled(true);
    ReloadSettings();
end;

procedure TfrmMHWRadio.OnChannelChange(CurrentProgramm: TMDProgram82);
var
    j: integer;
    TL: TListItem;
begin
    if mvarSaveRadioSettings and chkRadioOn.Enabled Then begin
        SaveRadioSettings();
    end;
    if butStop.Enabled Then begin
        //Stop recording!!!!!!
        butStop.Click;
    end;
    chkRadioOn.Checked:=false;
    chkRadioOn.Enabled:=false;
    lvNow.Clear;
    for j := 0 to 8 do begin
        TL:=TListItem.Create(lvNow.Items);
        TL.SubItems.Add('');
        TL.SubItems.Add('');
        TL.SubItems.Add('');
        TL.SubItems.Add('');
        TL.SubItems.Add('');
        TL.SubItems.Add('');
        TL:=lvNow.Items.AddItem(TL);
        TL.Caption:=inttostr(j+1);
        grdMapping.cells[0,j+1]:=inttostr(j+1);
        grdMapping.cells[1,j+1]:='';
        grdMapping.cells[2,j+1]:='';
    end;
    for j := 0 to 17 do begin
        mvarInformation[j].CRC32:=0;
    end;
end;

procedure TfrmMHWRadio.OnExit(MDInstance: THANDLE; MDWnd: HWND;
  Log_Set: Boolean);
begin
    if mvarSaveRadioSettings and chkRadioOn.Enabled Then begin
        SaveRadioSettings();
    end;
    if butStop.Enabled Then begin
        //Stop recording!!!
        butStop.Click;
    end;
    if RFilters.DescriptionsHandle<>-1 Then begin
        MD.StopFilter(RFilters.DescriptionsHandle,true);
        RFilters.DescriptionsHandle:=-1;
        FreeAndNil(RFilters.Descriptions184Filter);
    end;
end;

procedure TfrmMHWRadio.OnFilterClose(FilterOffset: DWORD);
begin
  inherited;

end;

procedure TfrmMHWRadio.OnFilterData(FilterHandle: integer;
  FilterData: PBYTEARRAY; DataLength: integer);
    procedure ID3CopyField(Source: pchar;Target: pchar; chars: integer);
    var
        i,j: integer;
    begin
        for i := 0 to chars-1 do begin
            if (Source+i)^=chr(0) then begin
                for j := i to chars-1 do begin
                    (Target+j)^:=chr(0);
                end;
                Exit;
            end;
            (Target+i)^:=(Source+i)^;
        end;

    end;
var
    pBuffer: Pointer;
    dwLength: DWORD;
    pInfo: PBYTEARRAY;
    s: TStringList;
    j: integer;
    po: PBYTEARRAY;
    io: integer;
    st: string;
    st2: string;
    ID3File: TFileStream;
    MyID3V1: TID3V100;
begin
  inherited;
    if FilterHandle=RFilters.DescriptionsHandle Then begin
        inc(iFilterTotalData,DataLength);
        RFilters.Descriptions184Filter.AddToBuffer(FilterData,DataLength);
        while RFilters.Descriptions184Filter.FillNextBitFilter do begin
            //Ok a table has been found
            RFilters.Descriptions184Filter.GetBitFilter(pBuffer,dwLength);
            pInfo:=PBYTEARRAY(pBuffer);
            if (pInfo[0]=$FA) and (pInfo[3]=$00) and (pInfo[4]=$64) Then begin
                if RFilters.Descriptions184Filter.CheckCRCTable(pInfo,dwLength) Then begin
                    mvarTablesBuffer.AddTable(pInfo);
                    if mvarTablesBuffer.IsComplete Then begin
                        S:=ParseRadioInfoPacket(mvarTablesBuffer);
                        if Assigned(S) Then begin
                            UpdateStructures($64,S);
                            S.Free;
                        end;
                        mvarTablesBuffer.Free;
                        mvarTablesBuffer:=TDVBTablesHolder.Create;
                    end;
                    case pInfo[4] of
                        $64: if lblGroup64.Color=clLime then lblGroup64.Color:=clSkyBlue else lblGroup64.Color:=clLime;
                        $66: if lblGroup66.Color=clLime then lblGroup66.Color:=clSkyBlue else lblGroup66.Color:=clLime;
                        $68: if lblGroup68.Color=clLime then lblGroup68.Color:=clSkyBlue else lblGroup68.Color:=clLime;
                 
...
...
(Not finished, please download and read the complete file)
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
About.rtf20.49 kB2005-03-15|17:16
changelog.txt4.26 kB2005-03-15|17:16
clean.bat92.00 B2005-01-05|02:35
DVBCore.pas31.98 kB2004-12-17|23:45
frmPPVInfo.dfm15.69 kB2004-12-19|19:54
frmPPVInfo.pas6.17 kB2005-03-03|01:02
01.96 kB
About.bmp3.05 kB2004-12-17|23:52
About.ico2.40 kB2004-12-17|23:52
Add.bmp1.30 kB2004-12-17|23:52
bluenote.ico7.23 kB2004-12-17|23:52
bug.jpg6.04 kB2005-01-05|02:35
CAM.ico2.40 kB2004-12-17|23:52
Close.bmp3.05 kB2004-12-17|23:52
EPG.bmp1.05 kB2005-01-05|21:10
EPG.ico1.37 kB2004-12-17|23:52
EPGOFF.bmp1.62 kB2004-12-17|23:52
EPGON.bmp1.62 kB2004-12-17|23:52
EPG_Gliph.bmp3.43 kB2004-12-17|23:52
Event.ico1.37 kB2004-12-17|23:52
jetons.ico1.37 kB2004-12-17|23:52
leftLogo.bmp9.96 kB2004-12-17|23:52
logger.ico1.68 kB2004-12-17|23:52
MagicWand.bmp1.30 kB2004-12-17|23:52
MagicWand.ico1.37 kB2004-12-17|23:52
MAS.ico1.37 kB2004-12-17|23:52
MENOS.ico1.37 kB2004-12-17|23:52
nemesis.ico4.19 kB2004-12-17|23:52
Phoenix.ico1.72 kB2004-12-17|23:52
Provider.ico1.37 kB2004-12-17|23:52
Remove.bmp1.30 kB2004-12-17|23:52
Reset.bmp3.05 kB2004-12-17|23:52
Restart.bmp1.30 kB2004-12-17|23:52
Save.bmp2.05 kB2004-12-17|23:52
scriptengine.ico7.23 kB2004-12-17|23:52
ScriptsEngine.bmp6.80 kB2004-12-17|23:52
Tools.bmp246.00 B2004-12-17|23:52
tuxprogramming.jpg4.15 kB2005-01-13|19:01
V9Card.jpg11.00 kB2005-03-03|01:02
IFSI_IniFiles.pas10.45 kB2004-12-19|19:54
MpgLib.DLL141.50 kB2004-12-24|17:03
PMCAM0.00 B2005-03-15|17:18
PMCAM4.67 kB2005-01-05|17:24
PMCAM4.69 kB2005-01-05|17:24
PMCAM4.52 kB2005-01-05|17:24
PMCAM.rc3.60 kB2004-12-17|23:47
PMCAM2.dpr6.30 kB2005-03-11|20:15
PMCAM2.res1.70 kB2005-03-15|17:16
PMCAM2StandAlone.dpr1.19 kB2005-03-03|01:02
PMCAM2StandAlone.res4.95 kB2005-03-11|20:15
PMCAMMenu.rc259.00 B2004-12-26|20:10
PMCAMMenu.RES162.25 kB2005-03-15|17:16
rUPClickSplitter.res740.00 B2004-12-19|19:54
santa_rock.jpg5.65 kB2004-12-24|17:59
UBitManager.pas4.18 kB2004-12-17|23:45
uDecode123.pas4.01 kB2004-12-29|01:33
UDVBConditionalAccessSystemNames.pas1.49 kB2004-12-17|23:45
UDVBCoreToMD.pas4.59 kB2004-12-17|23:45
UDVBPIDNames.pas1.23 kB2004-12-17|23:45
UDVBTablesHolder.pas2.68 kB2004-12-28|02:17
UEPGEntry.pas3.29 kB2004-12-17|23:45
UEPGMHW.dfm7.72 kB2005-01-11|02:38
UEPGMHW.pas40.85 kB2005-01-11|02:38
UfrmAddFilter.dfm6.86 kB2004-12-17|23:46
UfrmAddFilter.pas3.68 kB2004-12-17|23:45
UfrmCAM.dfm217.00 kB2005-03-15|03:22
UfrmCAM.pas159.37 kB2005-03-15|17:16
ufrmDLLForm.dfm420.00 B2004-12-19|19:54
ufrmDLLForm.pas1.87 kB2004-12-26|20:10
UfrmEMM.dfm1.28 kB2004-12-17|23:46
UfrmEMM.pas1.47 kB2004-12-17|23:45
UfrmEPGAdvanced.dfm7.01 kB2005-01-05|21:10
UfrmEPGAdvanced.pas2.56 kB2005-01-05|21:10
UfrmMHWEPGEntries.dfm3.81 kB2004-12-17|23:46
UfrmMHWEPGEntries.pas4.33 kB2004-12-17|23:45
ufrmMHWRadio.dfm35.85 kB2005-01-21|18:53
ufrmMHWRadio.pas37.84 kB2005-01-21|18:53
UfrmPMTDetails.dfm2.31 kB2005-01-21|18:53
UfrmPMTDetails.pas2.74 kB2005-01-21|18:53
UfrmWarningOnExit.dfm15.64 kB2005-01-05|21:10
UfrmWarningOnExit.pas1.44 kB2005-01-05|21:10
ULogEngine.pas15.89 kB2005-03-12|17:11
UMDDefs.pas4.07 kB2005-03-03|01:02
UMD_Impl.pas11.26 kB2005-03-03|01:02
United32.pas14.20 kB2004-12-17|23:45
UnitISO639_3.pas10.04 kB2005-03-03|01:02
UnitMDInterface.pas28.92 kB2005-03-15|03:22
UnitTimer.pas1.39 kB2004-12-17|23:45
Unit_CRC32.pas3.62 kB2004-12-17|23:45
uPESToTS.pas6.11 kB2005-03-03|01:02
UScriptFunctions.pas2.97 kB2005-01-03|16:45
UScriptsEditor.dfm58.10 kB2005-01-21|18:53
UScriptsEditor.pas22.02 kB2005-03-03|01:02
USECAManager.pas18.26 kB2005-03-03|01:02
USECATableStore.pas12.92 kB2004-12-17|23:45
USECA_EMM.pas7.74 kB2005-03-12|03:36
USmartCardISO.pas14.45 kB2004-12-17|23:45
UTfrmMultiDec.dfm407.00 B2005-01-21|18:53
UTfrmMultiDec.pas4.38 kB2005-01-21|18:53
UTranslate.pas6.49 kB2004-12-24|17:03
UTS184ToBitFilter.pas36.28 kB2005-03-11|20:15
uUPClickSplitter.dcr488.00 B2004-12-19|19:54
uUPClickSplitter.dcu18.09 kB2005-03-03|01:02
uUPClickSplitter.pas20.43 kB2004-12-26|20:10
PMCAM2_2.50.zip870.87 kB2016-03-19|22:08
...
Sponsored links

ufrmMHWRadio.pas (1.30 MB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D