I have a question that has kept me busy for the last days. I am working with the Asterisk AMI.
The AMI gives output like this.
Event: RTCPSent
Privilege: reporting,all
Channel: SIP/1001-00000000
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: <unknown>
CallerIDName: SIP/1001
ConnectedLineNum: <unknown>
ConnectedLineName: SIP/1001
Language: ja
AccountCode:
Context: phones
Exten: 1000
Priority: 4
Uniqueid: 1535617422.0
Linkedid: 1535617422.0
To: 111.108.30.208:61987
From: 172.31.21.5:20687
SSRC: 0x5847ea3c
PT: 200(SR)
Event: RTCPReceived
Privilege: reporting,all
Channel: SIP/1001-00000000
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: <unknown>
CallerIDName: SIP/1001
ConnectedLineNum: <unknown>
ConnectedLineName: SIP/1001
Language: ja
AccountCode:
Context: phones
Exten: 1000
Priority: 4
Uniqueid: 1535617422.0
Linkedid: 1535617422.0
To: 172.31.21.5:20687
From: 111.108.30.208:61987
RTT: 0.0116
SSRC: 0x235022ee
PT: 200(SR)
Event: RTCPSent
Privilege: reporting,all
Channel: SIP/1000-00000001
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: 1000
CallerIDName: SIP/1001
ConnectedLineNum: <unknown>
ConnectedLineName: SIP/1001
Language: ja
AccountCode:
Context: phones
Exten:
Priority: 1
Uniqueid: 1535617431.1
Linkedid: 1535617422.0
To: 111.108.30.208:61044
From: 172.31.21.5:20349
SSRC: 0x0cb019a0
PT: 200(SR)
Event: RTCPReceived
Privilege: reporting,all
Channel: SIP/1000-00000001
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: 1000
CallerIDName: SIP/1001
ConnectedLineNum: <unknown>
ConnectedLineName: SIP/1001
Language: ja
AccountCode:
Context: phones
Exten:
Priority: 1
Uniqueid: 1535617431.1
Linkedid: 1535617422.0
To: 172.31.21.5:20349
From: 111.108.30.208:61044
RTT: 0.0115
SSRC: 0x00294823
PT: 200(SR)
I collect the output with the fread() function.
fread($fp, 8192);
[$fp is the output like here above]
This works but gives the output line by line. The correct way to get this would be from a white space line till white space line.
Event: RTCPReceived
Privilege: reporting,all
Channel: SIP/1001-00000000
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: <unknown>
CallerIDName: SIP/1001
ConnectedLineNum: <unknown>
ConnectedLineName: SIP/1001
Language: ja
AccountCode:
Context: phones
Exten: 1000
Priority: 4
Uniqueid: 1535617422.0
Linkedid: 1535617422.0
To: 172.31.21.5:20687
From: 111.108.30.208:61987
RTT: 0.0116
SSRC: 0x235022ee
PT: 200(SR)
This way I could collect the information that is needed and do the following steps.
Is this possible with the fread function?
I need to read information like who picked up the phone or hangeup.
Your input would be as always highly appreciated