Skip to content

Commit

Permalink
for ossrs#293, ossrs#250, move the ts codec to kernel ts.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jan 25, 2015
1 parent d22e4e8 commit ea85ad2
Show file tree
Hide file tree
Showing 7 changed files with 829 additions and 800 deletions.
1 change: 1 addition & 0 deletions trunk/src/app/srs_app_hls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ using namespace std;
#include <srs_kernel_avc.hpp>
#include <srs_kernel_file.hpp>
#include <srs_rtmp_buffer.hpp>
#include <srs_kernel_ts.hpp>

// drop the segment when duration of ts too small.
#define SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS 100
Expand Down
23 changes: 22 additions & 1 deletion trunk/src/app/srs_app_mpegts_udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ using namespace std;
#include <srs_kernel_log.hpp>
#include <srs_app_config.hpp>

// Transport Stream packets are 188 bytes in length.
#define TS_PACKET_SIZE 188

#ifdef SRS_AUTO_STREAM_CASTER

SrsMpegtsOverUdp::SrsMpegtsOverUdp(SrsConfDirective* c)
Expand All @@ -51,10 +54,28 @@ int SrsMpegtsOverUdp::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf)
std::string peer_ip = inet_ntoa(from->sin_addr);
int peer_port = ntohs(from->sin_port);

// drop ts packet when size not modulus by 188
if (nb_buf < TS_PACKET_SIZE || (nb_buf % TS_PACKET_SIZE) != 0) {
srs_warn("udp: drop %s:%d packet %d bytes", peer_ip.c_str(), peer_port, nb_buf);
return ret;
}
srs_info("udp: got %s:%d packet %d bytes", peer_ip.c_str(), peer_port, nb_buf);

// TODO: FIXME: implements it.
// process each ts packet
for (int i = 0; i < nb_buf; i += TS_PACKET_SIZE) {
char* ts_packet = buf + i;
if ((ret = on_ts_packet(ts_packet)) != ERROR_SUCCESS) {
srs_warn("mpegts: ignore ts packet error. ret=%d", ret);
continue;
}
}

return ret;
}

int SrsMpegtsOverUdp::on_ts_packet(char* ts_packet)
{
int ret = ERROR_SUCCESS;
return ret;
}

Expand Down
5 changes: 5 additions & 0 deletions trunk/src/app/srs_app_mpegts_udp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class SrsMpegtsOverUdp
* @remark user should never use the buf, for it's a shared memory bytes.
*/
virtual int on_udp_packet(sockaddr_in* from, char* buf, int nb_buf);
private:
/**
* when got a ts packet, in size TS_PACKET_SIZE.
*/
virtual int on_ts_packet(char* ts_packet);
};

#endif
Expand Down
Loading

0 comments on commit ea85ad2

Please sign in to comment.