[Live-devel] Question about transferring TS files

Dixon Siu dixonsiu at mediaglue.co.jp
Thu May 27 15:39:00 PDT 2004


Hi Alan,

When I streamed a program stream using the SimpleRTPSink, I encountered the
same problem. I think that the depacketizer of the player cannot read the
stream properly. If you try to write your own receiver for the TS program
and write it to a file. You will find that video from the file is perfect. I
guess the solution is to have a filter for your player (VLC, WMP etc...).

The attached testMPEG1or2ProgramReceiver is modified from Live.com's
receiver according to Ross' suggestion. It works fine for me for testing
whether my server is streaming out properly.

Regards,
Dixon


> -----Original Message-----
> From: live-devel-bounces at ns.live.com
> [mailto:live-devel-bounces at ns.live.com]On Behalf Of Chin-Fu Tsao
> Sent: Thursday, May 27, 2004 11:41 AM
> To: live-devel at ns.live.com
> Cc: takaku_chiou at arcadyan.com
> Subject: [Live-devel] Question about transferring TS files
>
>
> Hi all,
>
> I used LiveMedia Library to transfer Transport Stream
> recently,but meet some
> problems.I changed the code setp by step according to the FAQ.But
> the frames
> received in the client seems wrong.I put my test result in the
> attach files.
> There are three files contained in attached file. One if screen
> captured when
> streaming TS(TS.JPG). One is messaged printed by mplayer(note). One is my
> source code for TS(MPEG2TSFileServerMediaSubsession.cpp). BTW. I
> think that
> this is not a bandwidth issue because i arrange whole bandwidth for the
> transmitting channel (100M)......
>
> any helps will be appreciated..
>
> Regards
> alan

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.688 / Virus Database: 449 - Release Date: 2004/05/18
-------------- next part --------------
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)

This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
more details.

You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
**********/
// Copyright (c) 1996-2000, Live Networks, Inc.  All rights reserved
// A test program that receives a RTP/RTCP multicast MPEG video stream,
// and outputs the resulting MPEG file stream to 'stdout'
// main program

#include "liveMedia.hh"
#include "GroupsockHelper.hh"

#include "BasicUsageEnvironment.hh"

// To receive a "source-specific multicast" (SSM) stream, uncomment this:
//#define USE_SSM 1

void afterPlaying(void* clientData); // forward

// A structure to hold the state of the current session.
// It is used in the "afterPlaying()" function to clean up the session.
struct sessionState_t {
  RTPSource* source;
  MediaSink* sink;
  RTCPInstance* rtcpInstance;
} sessionState;

UsageEnvironment* env;

int main(int argc, char** argv) {
  // Begin by setting up our usage environment:
  TaskScheduler* scheduler = BasicTaskScheduler::createNew();
  env = BasicUsageEnvironment::createNew(*scheduler);

  // Create the data sink for 'stdout':
  sessionState.sink = FileSink::createNew(*env, "programStream.mpg");
  // Note: The string "stdout" is handled as a special case.
  // A real file name could have been used instead.

  // Create 'groupsocks' for RTP and RTCP:
  char* sessionAddressStr = "239.255.42.42";
  // Note: If the session is unicast rather than multicast,
  // then replace this string with "0.0.0.0"

  const unsigned short rtpPortNum = 6970;
  const unsigned short rtcpPortNum = rtpPortNum+1;
  const unsigned char ttl = 7; // low, in case routers don't admin scope
  
  struct in_addr sessionAddress;
  sessionAddress.s_addr = our_inet_addr(sessionAddressStr);
  const Port rtpPort(rtpPortNum);
  const Port rtcpPort(rtcpPortNum);
  
  Groupsock rtpGroupsock(*env, sessionAddress, rtpPort, ttl);
  Groupsock rtcpGroupsock(*env, sessionAddress, rtcpPort, ttl);
  
  // Create the data source: a "MPEG Video RTP source"
  //sessionState.source = SimpleRTPSource::createNew(*env, &rtpGroupsock, 33, 90000, "mp2t");
  sessionState.source = SimpleRTPSource::createNew(*env, &rtpGroupsock, 127, 90000, "mp2p");
  // Create (and start) a 'RTCP instance' for the RTP source:
  const unsigned totalSessionBandwidth = 4500; // in kbps; for RTCP b/w share
  const unsigned maxCNAMElen = 100;
  unsigned char CNAME[maxCNAMElen+1];
  gethostname((char*)CNAME, maxCNAMElen);
  CNAME[maxCNAMElen] = '\0'; // just in case
  sessionState.rtcpInstance
    = RTCPInstance::createNew(*env, &rtcpGroupsock,
			      totalSessionBandwidth, CNAME,
			      NULL /* we're a client */, sessionState.source);
  // Note: This starts RTCP running automatically

  // Finally, start receiving the multicast stream:
  *env << "Beginning receiving multicast stream...\n";
  sessionState.sink->startPlaying(*sessionState.source, afterPlaying, NULL);

  env->taskScheduler().doEventLoop(); // does not return

  return 0; // only to prevent compiler warning
}


void afterPlaying(void* /*clientData*/) {
  *env << "...done receiving\n";

  // End by closing the media:
  Medium::close(sessionState.rtcpInstance); // Note: Sends a RTCP BYE
  Medium::close(sessionState.sink);
  Medium::close(sessionState.source);
}


More information about the live-devel mailing list