2012-10-10 2 views
0

RTMP 스트림을 다운로드하고 저장하려고합니다. 라이브러리에 대한 설명에서 나는 흐름을 유지하는 방법을 발견했습니다. 이 문제를 해결하도록 도와주세요.LIBRTMP dll을 사용하여 RTMP 스트림을 하드 디스크에 다운로드하고 저장하십시오.

var 
    MY_RTMP: RTMP; 
    URL_str: string; 
    MY_RTMPPacket: RTMPPacket; 
    URL_char: PAnsiChar; 
begin 
    URL_str: = 'rtmp ://localhost: 1935/Video/test.stream'; 
    MY_RTMP: = RTMP_Alloc; 
    RTMP_Init (MY_RTMP); 
    RTMP_SetupURL (MY_RTMP, pcchar (URL_str)); 
    RTMP_EnableWrite (MY_RTMP); 
    RTMP_Connect (MY_RTMP, MY_RTMPPacket); 
    RTMP_ConnectStream (MY_RTMP, 0); 
    RTMP_Read(); 

하지만 그것은 단지 서버 사용 RTMP_Read()에 연결할 수 있습니다 : 코드 내가 사용하는 결과를 얻기 위해 어떤 매개 변수를 전달해야하는지 모르기 때문에 도움을 받고 싶었습니다.

LibRTMP 정의 : 사용

LIBRTMP(3)  LIBRTMP(3) 
RTMPDump v2.4 2011-07-20 LIBRTMP(3) 


NAME 

librtmp − RTMPDump Real-Time Messaging Protocol API 
LIBRARY 

RTMPDump RTMP (librtmp, -lrtmp) 
SYNOPSIS 

#include <librtmp/rtmp.h> 
DESCRIPTION 

The Real-Time Messaging Protocol (RTMP) is used for streaming multimedia content across a TCP/IP network. This API provides most client functions and a few server functions needed to support RTMP, RTMP tunneled in HTTP (RTMPT), encrypted RTMP (RTMPE), RTMP over SSL/TLS (RTMPS) and tunneled variants of these encrypted types (RTMPTE, RTMPTS). The basic RTMP specification has been published by Adobe but this API was reverse-engineered without use of the Adobe specification. As such, it may deviate from any published specifications but it usually duplicates the actual behavior of the original Adobe clients. 
The RTMPDump software package includes a basic client utility program in rtmpdump(1), some sample servers, and a library used to provide programmatic access to the RTMP protocol. This man page gives an overview of the RTMP library routines. These routines are found in the -lrtmp library. Many other routines are also available, but they are not documented yet. 

The basic interaction is as follows. A session handle is created using RTMP_Alloc() and initialized using RTMP_Init(). All session parameters are provided using RTMP_SetupURL(). The network connection is established using RTMP_Connect(), and then the RTMP session is established using RTMP_ConnectStream(). The stream is read using RTMP_Read(). A client can publish a stream by calling RTMP_EnableWrite() before the RTMP_Connect() call, and then using RTMP_Write() after the session is established. While a stream is playing it may be paused and unpaused using RTMP_Pause(). The stream playback position can be moved using RTMP_Seek(). When RTMP_Read() returns 0 bytes, the stream is complete and may be closed using RTMP_Close(). The session handle is freed using RTMP_Free(). 

All data is transferred using FLV format. The basic session requires an RTMP URL. The RTMP URL format is of the form 

    rtmp[t][e|s]://hostname[:port][/app[/playpath]] 
Plain rtmp, as well as tunneled and encrypted sessions are supported. 

Additional options may be specified by appending space-separated key=value pairs to the URL. Special characters in values may need to be escaped to prevent misinterpretation by the option parser. The escape encoding uses a backslash followed by two hexadecimal digits representing the ASCII value of the character. E.g., spaces must be escaped as \20 and backslashes must be escaped as \5c. 

OPTIONS 

Network Parameters 

These options define how to connect to the media server. 
socks=host:port 
Use the specified SOCKS4 proxy. 
Connection Parameters 

These options define the content of the RTMP Connect request packet. If correct values are not provided, the media server will reject the connection attempt. 
app=name 
Name of application to connect to on the RTMP server. Overrides the app in the RTMP URL. Sometimes the librtmp URL parser cannot determine the app name automatically, so it must be given explicitly using this option. 
tcUrl=url 
URL of the target stream. Defaults to rtmp[t][e|s]://host[:port]/app. 
pageUrl=url 
URL of the web page in which the media was embedded. By default no value will be sent. 
swfUrl=url 
URL of the SWF player for the media. By default no value will be sent. 
flashVer=version 
Version of the Flash plugin used to run the SWF player. The default is "LNX 10,0,32,18". 
conn=type:data 
Append arbitrary AMF data to the Connect message. The type must be B for Boolean, N for number, S for string, O for object, or Z for null. For Booleans the data must be either 0 or 1 for FALSE or TRUE, respectively. Likewise for Objects the data must be 0 or 1 to end or begin an object, respectively. Data items in subobjects may be named, by prefixing the type with 'N' and specifying the name before the value, e.g. NB:myFlag:1. This option may be used multiple times to construct arbitrary AMF sequences. E.g. 
    conn=B:1 conn=S:authMe conn=O:1 conn=NN:code:1.23 conn=NS:flag:ok conn=O:0 
Session Parameters 

These options take effect after the Connect request has succeeded. 
playpath=path 
Overrides the playpath parsed from the RTMP URL. Sometimes the rtmpdump URL parser cannot determine the correct playpath automatically, so it must be given explicitly using this option. 
playlist=0|1 
If the value is 1 or TRUE, issue a set_playlist command before sending the play command. The playlist will just contain the current playpath. If the value is 0 or FALSE, the set_playlist command will not be sent. The default is FALSE. 
live=0|1 
Specify that the media is a live stream. No resuming or seeking in live streams is possible. 
subscribe=path 
Name of live stream to subscribe to. Defaults to playpath. 
start=num 
Start at num seconds into the stream. Not valid for live streams. 
stop=num 
Stop at num seconds into the stream. 
buffer=num 
Set buffer time to num milliseconds. The default is 30000. 
timeout=num 
Timeout the session after num seconds without receiving any data from the server. The default is 120. 
Security Parameters 

These options handle additional authentication requests from the server. 
token=key 
Key for SecureToken response, used if the server requires SecureToken authentication. 
jtv=JSON 
JSON token used by legacy Justin.tv servers. Invokes NetStream.Authenticate.UsherToken 
swfVfy=0|1 
If the value is 1 or TRUE, the SWF player is retrieved from the specified swfUrl for performing SWF Verification. The SWF hash and size (used in the verification step) are computed automatically. Also the SWF information is cached in a .swfinfo file in the user's home directory, so that it doesn't need to be retrieved and recalculated every time. The .swfinfo file records the SWF URL, the time it was fetched, the modification timestamp of the SWF file, its size, and its hash. By default, the cached info will be used for 30 days before re-checking. 
swfAge=days 
Specify how many days to use the cached SWF info before re-checking. Use 0 to always check the SWF URL. Note that if the check shows that the SWF file has the same modification timestamp as before, it will not be retrieved again. 
EXAMPLES 

An example character string suitable for use with RTMP_SetupURL(): 
    "rtmp://flashserver:1935/ondemand/thefile swfUrl=http://flashserver/player.swf swfVfy=1" 
ENVIRONMENT 

HOME 
The value of $HOME is used as the location for the .swfinfo file. 
FILES 

$HOME/.swfinfo 
Cache of SWF Verification information 
SEE ALSO 

rtmpdump(1), rtmpgw(8) 
AUTHORS 

Andrej Stepanchuk, Howard Chu, The Flvstreamer Team 
<http://rtmpdump.mplayerhq.hu> 

코드 :

{$IFDEF FPC} 
    {$MODE DELPHI} 
    {$PACKRECORDS C} 
{$ENDIF} 

unit lrtmp; 

interface 

uses windows, sockets, WinSock ; 

Const 
{$ifdef windows} 
    LibRtmp = 'librtmp'; // Library name 
    { matching lib version for librtmp.dll, needed for initialization } 
    RTMP_LIBRTMP_VER_STRING='2.3'; 
{$else windows} 
    LibRtmp = 'rtmp'; // Library name 
    { matching lib version for librtmp, needed for initialization } 
    RTMP_LIBRTMP_VER_STRING='2.3'; 
{$endif windows} 

//{$I inttypes} 

{AMF Constants} 
Const 
    AMF_NUMBER = 0; 
    AMF_BOOLEAN = 1; 
    AMF_STRING = 2; 
    AMF_OBJECT = 3; 
    AMF_MOVIECLIP = 4; 
    AMF_NULL = 5; 
    AMF_UNDEFINED = 6; 
    AMF_REFERENCE = 7; 
    AMF_ECMA_ARRAY = 8; 
    AMF_OBJECT_END = 9; 
    AMF_STRICT_ARRAY = 10; 
    AMF_DATE = 11; 
    AMF_LONG_STRING = 12; 
    AMF_UNSUPPORTED = 13; 
    AMF_RECORDSET = 14; 
    AMF_XML_DOC = 15; 
    AMF_TYPED_OBJECT = 16; 
    AMF_AVMPLUS = 17; 
    AMF_INVALID = $ff; 
    AMF3_UNDEFINED = 0; 
    AMF3_NULL = 1; 
    AMF3_FALSE = 2; 
    AMF3_TRUE = 3; 
    AMF3_INTEGER = 4; 
    AMF3_DOUBLE = 5; 
    AMF3_STRING = 6; 
    AMF3_XML_DOC = 7; 
    AMF3_DATE = 8; 
    AMF3_ARRAY = 9; 
    AMF3_OBJECT = 10; 
    AMF3_XML = 11; 
    AMF3_BYTE_ARRAY = 12; 

{RTMP Constants} 
const 
    RTMP_LIB_VERSION = $020300; 
    RTMP_FEATURE_HTTP = $01; 
    RTMP_FEATURE_ENC = $02; 
    RTMP_FEATURE_SSL = $04; 
    RTMP_FEATURE_MFP = $08; 
    RTMP_FEATURE_WRITE = $10; 
    RTMP_FEATURE_HTTP2 = $20; 
    RTMP_PROTOCOL_UNDEFINED = -(1); 
    RTMP_PROTOCOL_RTMP = 0; 
    RTMP_PROTOCOL_RTMPE = RTMP_FEATURE_ENC; 
    RTMP_PROTOCOL_RTMPT = RTMP_FEATURE_HTTP; 
    RTMP_PROTOCOL_RTMPS = RTMP_FEATURE_SSL; 
    RTMP_PROTOCOL_RTMPTE = RTMP_FEATURE_HTTP or RTMP_FEATURE_ENC; 
    RTMP_PROTOCOL_RTMPTS = RTMP_FEATURE_HTTP or RTMP_FEATURE_SSL; 
    RTMP_PROTOCOL_RTMFP = RTMP_FEATURE_MFP; 
    RTMP_DEFAULT_CHUNKSIZE = 128; 
    RTMP_BUFFER_CACHE_SIZE = 16*1024; 
    RTMP_CHANNELS = 65600; 
    RTMP_PACKET_TYPE_AUDIO = $08; 
    RTMP_PACKET_TYPE_VIDEO = $09; 
    RTMP_PACKET_TYPE_INFO = $12; 
    RTMP_MAX_HEADER_SIZE = 18; 
    RTMP_PACKET_SIZE_LARGE = 0; 
    RTMP_PACKET_SIZE_MEDIUM = 1; 
    RTMP_PACKET_SIZE_SMALL = 2; 
    RTMP_PACKET_SIZE_MINIMUM = 3; 
    RTMP_LF_AUTH = $0001; 
    RTMP_LF_LIVE = $0002; 
    RTMP_LF_SWFV = $0004; 
    RTMP_LF_PLST = $0008; 
    RTMP_LF_BUFX = $0010; 
    RTMP_LF_FTCU = $0020; 
    RTMP_SWF_HASHLEN = 32; 
    RTMP_READ_HEADER = $01; 
    RTMP_READ_RESUME = $02; 
    RTMP_READ_NO_IGNORE = $04; 
    RTMP_READ_GOTKF = $08; 
    RTMP_READ_GOTFLVK = $10; 
    RTMP_READ_SEEKING = $20; 
    RTMP_READ_COMPLETE = -(3); 
    RTMP_READ_ERROR = -(2); 
    RTMP_READ_EOF = -(1); 
    RTMP_READ_IGNORE = 0; 

var 
    FSocket : TSocket; 
    SockAddrB : TSockAddr; 
    WSAData : TWSAData; 

{AMF Types} 
Type 
char = AnsiChar; 
cint = longint; 
cchar = shortint; 
pcchar = ^cchar; 
uint8_t = Byte; 
uint32_t = LongWord; 
int8_t = char; 
int32_t = LongInt; 
unsigned_char = Byte; 
unsigned_int = LongWord; 
unsigned_short = Word; 
int16_t = smallint; 
cuchar = byte; 
pcuchar = ^cuchar; 
cushort = Word; 
cuint = LongWord; 
cshort = SmallInt; 
clong = LongInt; 

    AVal = record 
      av_val : pcchar; 
      av_len : cint; 
     end; 
    PAVal = ^AVal; 
    AMF3ClassDef = record 
      cd_name : AVal; 
      cd_externalizable : cchar; 
      cd_dynamic : cchar; 
      cd_num : cint; 
      cd_props : PAVal; 
     end; 
    PAMF3ClassDef = ^AMF3ClassDef; 
    AMF3DataType = Longint; 
    PAMF3DataType = ^AMF3DataType; 
    AMFDataType = Longint; 
    PAMFDataType = ^AMFDataType; 
    AMFObjectProperty = record 
      {undefined structure} 
     end; 
    PAMFObjectProperty = ^AMFObjectProperty; 
    AMFObject = record 
      o_num : cint; 
      o_props : PAMFObjectProperty; 
     end; 
    PAMFObject = ^AMFObject; 

{RTMP Types} 

Type 
    TArray0toRTMP_SWF_HASHLEN1OfUint8_t = array[0..(RTMP_SWF_HASHLEN)-1] of uint8_t; 
    TArray0toRTMP_SWF_HASHLEN101OfCchar = array[0..(RTMP_SWF_HASHLEN+10)-1] of cchar; 
    TArray0toRTMP_MAX_HEADER_SIZE1OfCchar = array[0..(RTMP_MAX_HEADER_SIZE)-1] of cchar; 
    TArray0toRTMP_CHANNELS1OfCint = array[0..(RTMP_CHANNELS)-1] of cint; 
    TArray0toRTMP_BUFFER_CACHE_SIZE1OfCchar = array[0..(RTMP_BUFFER_CACHE_SIZE)-1] of cchar; 
    TArray0to6OfPcchar = array[0..6] of pcchar; 

    SockAddr = record 
    sa_family: u_short; 
    sa_data: array[0..13] of Char; 
    end; 

    RTMPChunk = record 
     c_headerSize : cint; 
     c_chunkSize : cint; 
     c_chunk : pcchar; 
     c_header : TArray0toRTMP_MAX_HEADER_SIZE1OfCchar; 
    end; 

    PRTMPChunk = ^RTMPChunk; 

    RTMPPacket = record 
     m_headerType : uint8_t; 
     m_packetType : uint8_t; 
     m_hasAbsTimestamp : uint8_t; 
     m_nChannel : cint; 
     m_nTimeStamp : uint32_t; 
     m_nInfoField2 : int32_t; 
     m_nBodySize : uint32_t; 
     m_nBytesRead : uint32_t; 
     m_chunk : PRTMPChunk; 
     m_body : pcchar; 
    end; 

    PRTMPPacket = ^RTMPPacket; 
    TArray0toRTMP_CHANNELS1OfPRTMPPacket = array[0..(RTMP_CHANNELS)-1] of PRTMPPacket; 

    RTMPSockBuf = record 
     sb_socket : cint; 
     sb_size : cint; 
     sb_start : pcchar; 
     sb_buf : TArray0toRTMP_BUFFER_CACHE_SIZE1OfCchar; 
     sb_timedout : cint; 
     sb_ssl : pointer; 
    end; 

    RTMP_LNK = record 
     hostname : AVal; 
     sockshost : AVal; 
     playpath0 : AVal; 
     playpath : AVal; 
     tcUrl : AVal; 
     swfUrl : AVal; 
     pageUrl : AVal; 
     app : AVal; 
     auth : AVal; 
     flashVer : AVal; 
     subscribepath : AVal; 
     token : AVal; 
     extras : AMFObject; 
     edepth : cint; 
     seekTime : cint; 
     stopTime : cint; 
     lFlags : cint; 
     swfAge : cint; 
     protocol : cint; 
     timeout : cint; 
     socksport : cushort; 
     port : cushort; 
     dh : pointer; 
     rc4keyIn : pointer; 
     rc4keyOut : pointer; 
     SWFSize : uint32_t; 
     SWFHash : TArray0toRTMP_SWF_HASHLEN1OfUint8_t; 
     SWFVerificationResponse : TArray0toRTMP_SWF_HASHLEN101OfCchar; 
    end; 

    RTMP_READ = record 
     buf : pcchar; 
     bufpos : pcchar; 
     buflen : cuint; 
     timestamp : uint32_t; 
     dataType : uint8_t; 
     flags : uint8_t; 
     status : int8_t; 
     initialFrameType : uint8_t; 
     nResumeTS : uint32_t; 
     metaHeader : pcchar; 
     initialFrame : pcchar; 
     nMetaHeaderSize : uint32_t; 
     nInitialFrameSize : uint32_t; 
     nIgnoredFrameCounter : uint32_t; 
     nIgnoredFlvFrameCounter : uint32_t; 
    end; 

    RTMP_METHOD = record 
     name : AVal; 
     num : cint; 
    end; 

    PRTMP_METHOD = ^RTMP_METHOD; 

    RTMP = record 
     m_inChunkSize : cint; 
     m_outChunkSize : cint; 
     m_nBWCheckCounter : cint; 
     m_nBytesIn : cint; 
     m_nBytesInSent : cint; 
     m_nBufferMS : cint; 
     m_stream_id : cint; 
     m_mediaChannel : cint; 
     m_mediaStamp : uint32_t; 
     m_pauseStamp : uint32_t; 
     m_pausing : cint; 
     m_nServerBW : cint; 
     m_nClientBW : cint; 
     m_nClientBW2 : uint8_t; 
     m_bPlaying : uint8_t; 
     m_bSendEncoding : uint8_t; 
     m_bSendCounter : uint8_t; 
     m_numInvokes : cint; 
     m_numCalls : cint; 
     m_methodCalls : PRTMP_METHOD; 
     m_vecChannelsIn : TArray0toRTMP_CHANNELS1OfPRTMPPacket; 
     m_vecChannelsOut : TArray0toRTMP_CHANNELS1OfPRTMPPacket; 
     m_channelTimestamp : TArray0toRTMP_CHANNELS1OfCint; 
     m_fAudioCodecs : double; 
     m_fVideoCodecs : double; 
     m_fEncoding : double; 
     m_fDuration : double; 
     m_msgCounter : cint; 
     m_polling : cint; 
     m_resplen : cint; 
     m_unackd : cint; 
     m_clientID : AVal; 
     m_read : RTMP_READ; 
     m_write : RTMPPacket; 
     m_sb : RTMPSockBuf; 
     Link : RTMP_LNK; 
    end; 

    PRTMP = ^RTMP; 
    PRTMP_LNK = ^RTMP_LNK; 
    PRTMP_READ = ^RTMP_READ; 
    PRTMPSockBuf = ^RTMPSockBuf; 

{RTMP Variables} 
var 
    RTMPProtocolStringsLower : Array [0..6] of Pcchar; //array[0..(RTMP_CHANNELS)-1] 
    RTMP_DefaultFlashVer : AVal; 
    RTMP_ctrlC : cint; 
    {RTMPProtocolStringsLower : TArray0to6OfPcchar; cvar; external; 
    RTMP_DefaultFlashVer : AVal;cvar;external; 
    RTMP_ctrlC : cint;cvar;external;} 

{AMF Functions} 
function AMF_EncodeString(output:pcchar; outend:pcchar; var str:AVal):pcchar;cdecl;external 'librtmp.dll' name 'AMF_EncodeString'; //LibRtmp = 'librtmp'; 
function AMF_EncodeNumber(output:pcchar; outend:pcchar; dVal:double):pcchar;cdecl;external 'librtmp' name 'AMF_EncodeNumber'; 
function AMF_EncodeInt16(output:pcchar; outend:pcchar; nVal:cshort):pcchar;cdecl;external 'librtmp' name 'AMF_EncodeInt16'; 
function AMF_EncodeInt24(output:pcchar; outend:pcchar; nVal:cint):pcchar;cdecl;external 'librtmp' name 'AMF_EncodeInt24'; 
function AMF_EncodeInt32(output:pcchar; outend:pcchar; nVal:cint):pcchar;cdecl;external 'librtmp' name 'AMF_EncodeInt32'; 
function AMF_EncodeBoolean(output:pcchar; outend:pcchar; bVal:cint):pcchar;cdecl;external 'librtmp' name 'AMF_EncodeBoolean'; 
function AMF_EncodeNamedString(output:pcchar; outend:pcchar; var name:AVal; var value:AVal):pcchar;cdecl;external 'librtmp' name 'AMF_EncodeNamedString'; 
function AMF_EncodeNamedNumber(output:pcchar; outend:pcchar; var name:AVal; dVal:double):pcchar;cdecl;external 'librtmp' name 'AMF_EncodeNamedNumber'; 
function AMF_EncodeNamedBoolean(output:pcchar; outend:pcchar; var name:AVal; bVal:cint):pcchar;cdecl;external 'librtmp' name 'AMF_EncodeNamedBoolean'; 
function AMF_DecodeInt16(data:pcchar):cushort;cdecl;external 'librtmp' name 'AMF_DecodeInt16'; 
function AMF_DecodeInt24(data:pcchar):cuint;cdecl;external 'librtmp' name 'AMF_DecodeInt24'; 
function AMF_DecodeInt32(data:pcchar):cuint;cdecl;external 'librtmp' name 'AMF_DecodeInt32'; 
procedure AMF_DecodeString(data:pcchar; var str:AVal);cdecl;external 'librtmp' name 'AMF_DecodeString'; 
procedure AMF_DecodeLongString(data:pcchar; var str:AVal);cdecl;external 'librtmp' name 'AMF_DecodeLongString'; 
function AMF_DecodeBoolean(data:pcchar):cint;cdecl;external 'librtmp' name 'AMF_DecodeBoolean'; 
function AMF_DecodeNumber(data:pcchar):double;cdecl;external 'librtmp' name 'AMF_DecodeNumber'; 
function AMF_Encode(var obj:AMFObject; pBuffer:pcchar; pBufEnd:pcchar):pcchar;cdecl;external 'librtmp' name 'AMF_Encode'; 
function AMF_Decode(var obj:AMFObject; pBuffer:pcchar; nSize:cint; bDecodeName:cint):cint;cdecl;external 'librtmp' name 'AMF_Decode'; 
function AMF_DecodeArray(var obj:AMFObject; pBuffer:pcchar; nSize:cint; nArrayLen:cint; bDecodeName:cint):cint;cdecl;external 'librtmp' name 'AMF_DecodeArray'; 
function AMF3_Decode(var obj:AMFObject; pBuffer:pcchar; nSize:cint; bDecodeName:cint):cint;cdecl;external 'librtmp' name 'AMF3_Decode'; 
procedure AMF_Dump(var obj:AMFObject);cdecl;external 'librtmp' name 'AMF_Dump'; 
procedure AMF_Reset(var obj:AMFObject);cdecl;external 'librtmp' name 'AMF_Reset'; 
procedure AMF_AddProp(var obj:AMFObject; var prop:AMFObjectProperty);cdecl;external 'librtmp' name 'AMF_AddProp'; 
function AMF_CountProp(var obj:AMFObject):cint;cdecl;external 'librtmp' name 'AMF_CountProp'; 
function AMF_GetProp(var obj:AMFObject; var name:AVal; nIndex:cint):PAMFObjectProperty;cdecl;external 'librtmp' name 'AMF_GetProp'; 
function AMFProp_GetType(var prop:AMFObjectProperty):AMFDataType;cdecl;external 'librtmp' name 'AMFProp_GetType'; 
procedure AMFProp_SetNumber(var prop:AMFObjectProperty; dval:double);cdecl;external 'librtmp' name 'AMFProp_SetNumber'; 
procedure AMFProp_SetBoolean(var prop:AMFObjectProperty; bflag:cint);cdecl;external 'librtmp' name 'AMFProp_SetBoolean'; 
procedure AMFProp_SetString(var prop:AMFObjectProperty; var str:AVal);cdecl;external 'librtmp' name 'AMFProp_SetString'; 
procedure AMFProp_SetObject(var prop:AMFObjectProperty; var obj:AMFObject);cdecl;external 'librtmp' name 'AMFProp_SetObject'; 
procedure AMFProp_GetName(var prop:AMFObjectProperty; var name:AVal);cdecl;external 'librtmp' name 'AMFProp_GetName'; 
procedure AMFProp_SetName(var prop:AMFObjectProperty; var name:AVal);cdecl;external 'librtmp' name 'AMFProp_SetName'; 
function AMFProp_GetNumber(var prop:AMFObjectProperty):double;cdecl;external 'librtmp' name 'AMFProp_GetNumber'; 
function AMFProp_GetBoolean(var prop:AMFObjectProperty):cint;cdecl;external 'librtmp' name 'AMFProp_GetBoolean'; 
procedure AMFProp_GetString(var prop:AMFObjectProperty; var str:AVal);cdecl;external 'librtmp' name 'AMFProp_GetString'; 
procedure AMFProp_GetObject(var prop:AMFObjectProperty; var obj:AMFObject);cdecl;external 'librtmp' name 'AMFProp_GetObject'; 
function AMFProp_IsValid(var prop:AMFObjectProperty):cint;cdecl;external 'librtmp' name 'AMFProp_IsValid'; 
function AMFProp_Encode(var prop:AMFObjectProperty; pBuffer:pcchar; pBufEnd:pcchar):pcchar;cdecl;external 'librtmp' name 'AMFProp_Encode'; 
function AMF3Prop_Decode(var prop:AMFObjectProperty; pBuffer:pcchar; nSize:cint; bDecodeName:cint):cint;cdecl;external 'librtmp' name 'AMF3Prop_Decode'; 
function AMFProp_Decode(var prop:AMFObjectProperty; pBuffer:pcchar; nSize:cint; bDecodeName:cint):cint;cdecl;external 'librtmp' name 'AMFProp_Decode'; 
procedure AMFProp_Dump(var prop:AMFObjectProperty);cdecl;external 'librtmp' name 'AMFProp_Dump'; 
procedure AMFProp_Reset(var prop:AMFObjectProperty);cdecl;external 'librtmp' name 'AMFProp_Reset'; 
procedure AMF3CD_AddProp(var cd:AMF3ClassDef; var prop:AVal);cdecl;external 'librtmp' name 'AMF3CD_AddProp'; 
function AMF3CD_GetProp(var cd:AMF3ClassDef; idx:cint):PAVal;cdecl;external 'librtmp' name 'AMF3CD_GetProp'; 

{RTMP Functions} 
procedure RTMPPacket_Reset(var p:RTMPPacket);cdecl;external 'librtmp' name 'RTMPPacket_Reset'; 
procedure RTMPPacket_Dump(var p:RTMPPacket);cdecl;external 'librtmp' name 'RTMPPacket_Dump'; 
function RTMPPacket_Alloc(var p:RTMPPacket; nSize:cint):cint;cdecl;external 'librtmp' name 'RTMPPacket_Alloc'; 
procedure RTMPPacket_Free(var p:RTMPPacket);cdecl;external 'librtmp' name 'RTMPPacket_Free'; 
function RTMP_GetTime:uint32_t;cdecl;external 'librtmp' name 'RTMP_GetTime'; 
function RTMP_ParseURL(url:pcchar; var protocol:cint; var host:AVal; var port:cuint; var playpath:AVal; 
      var app:AVal):cint;cdecl;external 'librtmp' name 'RTMP_ParseURL'; 
procedure RTMP_ParsePlaypath(var input:AVal; var output:AVal);cdecl;external 'librtmp' name 'RTMP_ParsePlaypath'; 
procedure RTMP_SetBufferMS(var r:RTMP; size:cint);cdecl;external 'librtmp' name 'RTMP_SetBufferMS'; 
procedure RTMP_UpdateBufferMS(var r:RTMP);cdecl;external 'librtmp' name 'RTMP_UpdateBufferMS'; 
function RTMP_SetOpt(var r:RTMP; var opt:AVal; var arg:AVal):cint;cdecl;external 'librtmp' name 'RTMP_SetOpt'; 
function RTMP_SetupURL(var r:RTMP; url:pcchar):cint;cdecl;external 'librtmp' name 'RTMP_SetupURL'; 
procedure RTMP_SetupStream(var r:RTMP; protocol:cint; var hostname:AVal; port:cuint; var sockshost:AVal; 
      var playpath:AVal; var tcUrl:AVal; var swfUrl:AVal; var pageUrl:AVal; var app:AVal; 
      var auth:AVal; var swfSHA256Hash:AVal; swfSize:uint32_t; var flashVer:AVal; var subscribepath:AVal; 
      dStart:cint; dStop:cint; bLiveStream:cint; timeout:clong);cdecl;external 'librtmp' name 'RTMP_SetupStream'; 
function RTMP_Connect(var r:RTMP; var cp:RTMPPacket):cint;cdecl;external 'librtmp' name 'RTMP_Connect'; 
function RTMP_Connect0(var r:RTMP; var svc:sockaddr):cint;cdecl;external 'librtmp' name 'RTMP_Connect0'; 
function RTMP_Connect1(var r:RTMP; var cp:RTMPPacket):cint;cdecl;external 'librtmp' name 'RTMP_Connect1'; 
function RTMP_Serve(var r:RTMP):cint;cdecl;external 'librtmp' name 'RTMP_Serve'; 
function RTMP_ReadPacket(var r:RTMP; var packet:RTMPPacket):cint;cdecl;external 'librtmp' name 'RTMP_ReadPacket'; 
function RTMP_SendPacket(var r:RTMP; var packet:RTMPPacket; queue:cint):cint;cdecl;external 'librtmp' name 'RTMP_SendPacket'; 
function RTMP_SendChunk(var r:RTMP; var chunk:RTMPChunk):cint;cdecl;external 'librtmp' name 'RTMP_SendChunk'; 
function RTMP_IsConnected(var r:RTMP):cint;cdecl;external 'librtmp' name 'RTMP_IsConnected'; 
function RTMP_Socket(var r:RTMP):cint;cdecl;external 'librtmp' name 'RTMP_Socket'; 
function RTMP_IsTimedout(var r:RTMP):cint;cdecl;external 'librtmp' name 'RTMP_IsTimedout'; 
function RTMP_GetDuration(var r:RTMP):double;cdecl;external 'librtmp' name 'RTMP_GetDuration'; 
function RTMP_ToggleStream(var r:RTMP):cint;cdecl;external 'librtmp' name 'RTMP_ToggleStream'; 
function RTMP_ConnectStream(var r:RTMP; seekTime:cint):cint;cdecl;external 'librtmp' name 'RTMP_ConnectStream'; 
function RTMP_ReconnectStream(var r:RTMP; seekTime:cint):cint;cdecl;external 'librtmp' name 'RTMP_ReconnectStream'; 
procedure RTMP_DeleteStream(var r:RTMP);cdecl;external 'librtmp' name 'RTMP_DeleteStream'; 
function RTMP_GetNextMediaPacket(var r:RTMP; var packet:RTMPPacket):cint;cdecl;external 'librtmp' name 'RTMP_GetNextMediaPacket'; 
function RTMP_ClientPacket(var r:RTMP; var packet:RTMPPacket):cint;cdecl;external 'librtmp' name 'RTMP_ClientPacket'; 
procedure RTMP_Init(var r:RTMP);cdecl;external 'librtmp' name 'RTMP_Init'; 
procedure RTMP_Close(var r:RTMP);cdecl;external 'librtmp' name 'RTMP_Close'; 
function RTMP_Alloc:RTMP;cdecl;external 'librtmp' name 'RTMP_Alloc'; 
procedure RTMP_Free(var r:RTMP);cdecl;external 'librtmp' name 'RTMP_Free'; 
procedure RTMP_EnableWrite(var r:RTMP);cdecl;external 'librtmp' name 'RTMP_EnableWrite'; 
function RTMP_LibVersion:cint;cdecl;external 'librtmp' name 'RTMP_LibVersion'; 
procedure RTMP_UserInterrupt;cdecl;external 'librtmp' name 'RTMP_UserInterrupt'; 
function RTMP_SendCtrl(var r:RTMP; nType:cshort; nObject:cuint; nTime:cuint):cint;cdecl;external 'librtmp' name 'RTMP_SendCtrl'; 
function RTMP_SendPause(var r:RTMP; DoPause:cint; dTime:cint):cint;cdecl;external 'librtmp' name 'RTMP_SendPause'; 
function RTMP_Pause(var r:RTMP; DoPause:cint):cint;cdecl;external 'librtmp' name 'RTMP_Pause'; 
function RTMP_FindFirstMatchingProperty(var obj:AMFObject; var name:AVal; var p:AMFObjectProperty):cint;cdecl;external 'librtmp' name 'RTMP_FindFirstMatchingProperty'; 
function RTMPSockBuf_Fill(var sb:RTMPSockBuf):cint;cdecl;external 'librtmp' name 'RTMPSockBuf_Fill'; 
function RTMPSockBuf_Send(var sb:RTMPSockBuf; buf:pcchar; len:cint):cint;cdecl;external 'librtmp' name 'RTMPSockBuf_Send'; 
function RTMPSockBuf_Close(var sb:RTMPSockBuf):cint;cdecl;external 'librtmp' name 'RTMPSockBuf_Close'; 
function RTMP_SendCreateStream(var r:RTMP):cint;cdecl;external 'librtmp' name 'RTMP_SendCreateStream'; 
function RTMP_SendSeek(var r:RTMP; dTime:cint):cint;cdecl;external 'librtmp' name 'RTMP_SendSeek'; 
function RTMP_SendServerBW(var r:RTMP):cint;cdecl;external 'librtmp' name 'RTMP_SendServerBW'; 
function RTMP_SendClientBW(var r:RTMP):cint;cdecl;external 'librtmp' name 'RTMP_SendClientBW'; 
procedure RTMP_DropRequest(var r:RTMP; i:cint; freeit:cint);cdecl;external 'librtmp' name 'RTMP_DropRequest'; 
function RTMP_ReadData(var r:RTMP; buf:pcchar; size:cint):cint;cdecl;external 'librtmp' name 'RTMP_ReadData'; 
function RTMP_WriteData(var r:RTMP; buf:pcchar; size:cint):cint;cdecl;external 'librtmp' name 'RTMP_WriteData'; 
function RTMP_HashSWF(url:pcchar; var size:cuint; hash:pcuchar; age:cint):cint;cdecl;external 'librtmp' name 'RTMP_HashSWF'; 

implementation 


end. 
+1

-1이 답변을 어떻게 알 수 있습니까? 이미 읽었을 것으로 기대되는이 라이브러리의 문서에 대한 링크를 제공하십시오. 파스칼 헤더 번역에 대한 링크를 제공해주십시오. 코드에서 기대하는 바를 제공하고 실패한 방법에 대해 자세히 알려주십시오. 이 질문에 관심이 있다는 것을 보여주십시오. 우리가 당신을 돌보고 있다고 생각하면 우리가 돌볼 기회가 더 많습니다. 지금은 마치 게으른 것처럼 보이고 우리가 당신을 위해 모든 것을하기를 원합니다. 질문에 더 많은 노력을 기울이십시오. 문제를 개선 할 수 없다면 투표를 닫을 것입니다. [faq] –

+0

documentation library librtmp : [링크] (http://rtmpdump.mplayerhq.hu/librtmp.3.html) – Anvar

+0

댓글에 없습니다. 질문에 대한 링크를 추가하십시오. 질문 아래의 ** 수정 ** 링크를 클릭하고 질문을 개선하십시오. 어쨌든,'RTMP_Read'에 대한 호출은 어디에 있습니까? –

답변

1

문서에 따르면, 당신은

RTMP_Read() 

반복 스트림을 읽어 호출해야합니다. 함수에 버퍼를 전달하면 함수가 스트림의 다음 부분을 채 웁니다. 함수가 0을 반환하면 스트림 전체가 읽혔다는 것을 의미합니다.

procedure ReadStream(rtmp: RTMP; Stream: TStream); 
var 
    Buffer: array [0..16384-1] of Byte;//16kB buffer 
    BytesRead: Integer; 
begin 
    while True do 
    begin 
    BytesRead := RTMP_Read(rtmp, @Buffer[0], SizeOf(Buffer)); 
    if BytesRead=0 then 
     exit; 
    Stream.WriteBuffer(@Buffer[0], BytesRead); 
    end; 

내가 찾고 있어요 문서는 RTMP_Read라는 기능이 있습니다

코드는 다음과 같은 것이다. 하지만 수입 단위는 RTMP_ReadData입니다. 그 불일치가 어디서 왔는지 나는 잘 모르겠습니다.

나는 또한 당신이 사용하는 헤더 번역에 확신하지 못한다. pcchar 대신 PByte을 쓰고 cint 대신 Integer을 쓸 것입니다.

+0

RTMP_Read()를 사용하십시오. 결과를 얻기 위해 어떤 매개 변수를 전달해야하는지 모르기 때문에 도움을 받고 싶었습니다. – Anvar

+0

대단히 감사합니다. 제공하신 코드를 공부하겠습니다. – Anvar

+0

즉시 수락해야한다고 생각하지 마십시오. 자유롭게 시도해보고 내가 완전히 틀린다면 받아들이지 마라! 나는 내가 상사 인 것을 알고있다! 조언을 듣고 경청 해 주셔서 감사합니다. –

관련 문제