Closed GoogleCodeExporter closed 9 years ago
Does it work with rtmpdump?
Original comment by bborgsd...@gmail.com
on 10 Jul 2011 at 9:49
Hi bborgsdorf,
I don't know :o)
What's happining here, that I was wondering a few weeks ago, how great
implementation is this for develope RTMP clients in C#, but unfortunatelly it
is restrected to download viedos only. So I decided to modify RTMP_LIB code to
be able to connect to media servers for general puposes, just like connecting
to chat servers, sharedobjects, and live streams. It is working perfectly for
rtmp but I realized serious problems at rtmpe includeing handshake, and invokes
as well.
Concerning the problem descibed above:
I've just realized, that if I change offalg to message format2 it is working!
It seems, some of the rtmpe servers using message format2 in seconde part of
handshake. If I use something like this, it seems both cases I find server
signature:
// 2nd part of handshake
byte[] resp = new byte[RTMP.RTMP_SIG_SIZE];
if (ReadN(resp, 0, RTMP.RTMP_SIG_SIZE) != RTMP.RTMP_SIG_SIZE) return false;
if (FP9HandShake)
{
bool bSignatureFound=true;
int digestPosClient=0;
byte[] signature=null;
byte[] digest=null;
if (resp[4] == 0 && resp[5] == 0 && resp[6] == 0 && resp[7] == 0)
{
logger.Log("Wait, did the server just refuse signed authentication?");
}
// verify server response
//offalg ^= 1;
digestPosClient = (int)GetDigestOffset(offalg, clientsig, 1, RTMP.RTMP_SIG_SIZE);
signature = new byte[RTMP.SHA256_DIGEST_LENGTH];
digest = new byte[RTMP.SHA256_DIGEST_LENGTH];
logger.Log(string.Format("Client signature digest position: {0}", digestPosClient));
HMACsha256(clientsig, 1 + digestPosClient, RTMP.SHA256_DIGEST_LENGTH, RTMP.GenuineFMSKey, RTMP.GenuineFMSKey.Length, digest, 0);
HMACsha256(resp, 0, RTMP.RTMP_SIG_SIZE - RTMP.SHA256_DIGEST_LENGTH, digest, RTMP.SHA256_DIGEST_LENGTH, signature, 0);
// show some information
logger.Log("Digest key: ");
logger.LogHex(digest, 0, RTMP.SHA256_DIGEST_LENGTH);
// FP10 stuff
if (type == 8)
{
/* encrypt signatureResp */
for (int i = 0; i < RTMP.SHA256_DIGEST_LENGTH; i += 8)
rtmpe8_sig(signature, i, digest[i] % 15);
}
logger.Log("Signature calculated:");
logger.LogHex(signature, 0, RTMP.SHA256_DIGEST_LENGTH);
logger.Log("Server sent signature:");
logger.LogHex(resp, RTMP.RTMP_SIG_SIZE - RTMP.SHA256_DIGEST_LENGTH, RTMP.SHA256_DIGEST_LENGTH);
for (int i = 0; i < RTMP.SHA256_DIGEST_LENGTH; i++)
{
if (signature[i] != resp[RTMP.RTMP_SIG_SIZE - RTMP.SHA256_DIGEST_LENGTH + i])
{
logger.Log("Signature not found, let's try changing the alg(message format2)!");
bSignatureFound=false;
break;
}
}
if(!bSignatureFound)
{
offalg ^= 1;
digestPosClient = (int)GetDigestOffset(offalg, clientsig, 1, RTMP.RTMP_SIG_SIZE);
signature = new byte[RTMP.SHA256_DIGEST_LENGTH];
digest = new byte[RTMP.SHA256_DIGEST_LENGTH];
logger.Log(string.Format("Client signature digest position: {0}", digestPosClient));
HMACsha256(clientsig, 1 + digestPosClient, RTMP.SHA256_DIGEST_LENGTH, RTMP.GenuineFMSKey, RTMP.GenuineFMSKey.Length, digest, 0);
HMACsha256(resp, 0, RTMP.RTMP_SIG_SIZE - RTMP.SHA256_DIGEST_LENGTH, digest, RTMP.SHA256_DIGEST_LENGTH, signature, 0);
// show some information
logger.Log("Digest key: ");
logger.LogHex(digest, 0, RTMP.SHA256_DIGEST_LENGTH);
// FP10 stuff
if (type == 8)
{
/* encrypt signatureResp */
for (int i = 0; i < RTMP.SHA256_DIGEST_LENGTH; i += 8)
rtmpe8_sig(signature, i, digest[i] % 15);
}
logger.Log("Signature calculated:");
logger.LogHex(signature, 0, RTMP.SHA256_DIGEST_LENGTH);
logger.Log("Server sent signature:");
logger.LogHex(resp, RTMP.RTMP_SIG_SIZE - RTMP.SHA256_DIGEST_LENGTH, RTMP.SHA256_DIGEST_LENGTH);
for (int i = 0; i < RTMP.SHA256_DIGEST_LENGTH; i++)
{
byte b=resp[RTMP.RTMP_SIG_SIZE - RTMP.SHA256_DIGEST_LENGTH + i];
if (signature[i] != resp[RTMP.RTMP_SIG_SIZE - RTMP.SHA256_DIGEST_LENGTH + i])
{
logger.Log("Server not genuine Adobe!");
return false;
}
}
}
logger.Log("Genuine Adobe Flash Media Server");
I know it's very trivial solution but seems to be working...
After successful connection, server sends packages, what RTMP_LIB can't
recognize, I don't know why, I just start investigate.
If I ask you to help me in this issue would you be so kind to do it?
Of course I'm happy to share the code here if you think it can be useful.
(I implement NetConnection,SharedObject and NetStream classes for general
purpose usage of RTMP_LIB)
Thanks again,
Ferike
Original comment by fvarko...@hotmail.com
on 10 Jul 2011 at 10:26
Sure we can work together to make this lib much more complete!
But I have to say, I have no real knowledge about all this. The c# you find
here is roughly a clone of the rtmpdump c++ lib, that I brought into the .net
world :)
Original comment by bborgsd...@gmail.com
on 10 Jul 2011 at 11:25
Yeah, ok!
My real problem that I have no knowladge in cryptography used by RTMPE!
Maybe the best solution if I upload the best code I can attchieve here asking
experts to improve it. I had to modify TCP connect to detach the connection
from the GUI(this is needed for desktop applications) so I implemented async
socket connection and some other manior modifacation I did. This reason,I
renamed the library to RTMP_CLIENT.
I also had to update bouncycastle to the newiest version, because the one it is
used in RTMP_LIB caused arithmetic exception at RTMPE. If you aggree I upload
all what I have next to RTMP_LIB. If later when problems fixed and it is
thought useful RTMP_LIB can be changed to RTMP_CLIENT with few effords. At the
moment, the whole project needs to be tested, and of course all prealpha :o))
Original comment by fvarko...@hotmail.com
on 10 Jul 2011 at 11:52
You could also start a new project here on google code for your improved lib.
And when it's stable enough we can integrate it here here well. This way
there's a common rtmp client lib in c# available that can be used in many apps
- should get more attraction.
I can then integrate that lib into the onlinevideos project.
Original comment by bborgsd...@gmail.com
on 10 Jul 2011 at 12:04
Ok! I will upload the code in a separated google code project in the next few
days(I wanna make the scripts more clear, and commented till then) and I will
inform you about it on this site.
Thanks for your help.
Original comment by fvarko...@hotmail.com
on 10 Jul 2011 at 12:14
Hi again,
I uploaded the project here:
http://code.google.com/p/rtmpconnector/
I tested NetConnection, SharedObject functionalities on some public chat
applications and on Red5, and adobe FMS servers installed localy and they looks
ok :O) (I mean RTMP connection. RTMPE handshake still problematic in some
cases, other cases it's working)
I also tried NetStream functionalities and generaly its working, but I think
there is still much work with it (Actually I did not modified the origin code,
only commented out some parts I thought not important in this project. Those
parts might must be reused later).
I did not implemented getLocal funcionality on SharedObject, cause I don't find
it important in C# environment.
I also try to convert AMF typed-objects to Dictionary type because it's
regularly used.
At the moment I'm still testing features of NetConnection and SharedObject
types.
I would be happy if you or anybody else, participating your project, could test
and/or help improve this project as well.
Ferike
Original comment by fvarko...@hotmail.com
on 20 Jul 2011 at 11:53
The repository on your url doesn't seem contain any source code yet?
Original comment by bborgsd...@gmail.com
on 25 Jul 2011 at 4:57
Hi again!
Realy I just uploaded a zip file to download section. I'm not familiar with
googlecode yet, so I have to find out yet how to upload the source section :o)
I'm still modifying the code by the way, there is a lots of bug and I realized
some missunderstanding I had while reading your code.
I'm in a big Sh***t concerining playing the live stream real time at the
moment, I realized its not easy at all. Do you have any Idea how could I
implement a player, can play flv from memorystream? I have found some advice in
forums, but looks every solutions quite difficult, like implementing COM
interface for directshow and so on... I would like to implement a very simple
player what can attach the straem to ( like video class attachNetStream in AS3).
I think I mixed the timestamping you did in RTMP class, must be fixt in the
near future.
Thanks for keeping the contact,
Ferike
Original comment by fvarko...@hotmail.com
on 27 Jul 2011 at 3:16
Playback is not easy for sure, because rtmp delivered streams can have many
formats. The way it's done in the MediaPortal plugin is the easiest: Hand the
stream to a directshow graph.
I didn't look in the downloads section of you project :) A code project should
have the code checked in. As you started a git project you should make yourself
familiar with the versioning system git.
Original comment by bborgsd...@gmail.com
on 27 Jul 2011 at 3:27
Thanks!
Do you play the stream directly from memory on mediaportal? From memorystraem
for exapmle? Or you give the url to the player? Thats the big question.
In my understanding I can't forward the url to the player in case livestream,
cause its simply not exists.
I plan to investigate this part of your code more deeply from now, the best
solutions would be if I can copy this part from you, could save a lot off
effort for me, I can pay for other issues of rtmpconnector :o))
I will learn the versioning system in the near future, I promiss, but till then
I just wanna upload the project in zip file, if I mad some debug on it.
Original comment by fvarko...@hotmail.com
on 27 Jul 2011 at 3:42
My code has a local http server that acts as proxy to the directshow graph. So
the directshow filters think they play a http file. That's a protocol we have a
filter for.
Original comment by bborgsd...@gmail.com
on 27 Jul 2011 at 3:44
hm, tricky, I will check this solution
Original comment by fvarko...@hotmail.com
on 27 Jul 2011 at 3:48
Hi again,
At the end I created a source filter to play video directly from stream, also
some bugs fixed. The player is not too sophisticated yet and not working
properly, I tried many things but I can't play video and audio streams
together(separetedly works..). This can be problem with time stamping, memmory
allocator issue, or something different. I also uploded the source section on
git. Can you overview the player and recommend how to modify (or anybody here
is expert at directshow and willing to help me?)
RTMPE still not working for me, I don't know how can work in onlinevideo
project.
Might be depends on the server connected to...
Thank you
Original comment by fvarko...@hotmail.com
on 17 Sep 2011 at 6:05
We also created a source filter for rtmp now that uses rtmplib. So the C#
implementation has become almost obsolete.
Original comment by bborgsd...@gmail.com
on 9 Jan 2012 at 4:36
Original issue reported on code.google.com by
fvarko...@hotmail.com
on 10 Jul 2011 at 7:20