Skip to content

Commit

Permalink
fix: wrong nalunit judgement.
Browse files Browse the repository at this point in the history
  • Loading branch information
SighingSnow committed Nov 18, 2021
1 parent 59db4d3 commit bc77c84
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
28 changes: 14 additions & 14 deletions src/h264fileparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ void H264FileParser::loadNextSample(std::vector<std::byte>& buffer) {
}

vector<byte> H264FileParser::initialNALUS() {
// vector<byte> units{};
// if (previousUnitType7.has_value()) {
// auto nalu = previousUnitType7.value();
// units.insert(units.end(), nalu.begin(), nalu.end());
// }
// if (previousUnitType8.has_value()) {
// auto nalu = previousUnitType8.value();
// units.insert(units.end(), nalu.begin(), nalu.end());
// }
// if (previousUnitType5.has_value()) {
// auto nalu = previousUnitType5.value();
// units.insert(units.end(), nalu.begin(), nalu.end());
// }
// return units;
vector<byte> units{};
if (previousUnitType7.has_value()) {
auto nalu = previousUnitType7.value();
units.insert(units.end(), nalu.begin(), nalu.end());
}
if (previousUnitType8.has_value()) {
auto nalu = previousUnitType8.value();
units.insert(units.end(), nalu.begin(), nalu.end());
}
if (previousUnitType5.has_value()) {
auto nalu = previousUnitType5.value();
units.insert(units.end(), nalu.begin(), nalu.end());
}
return units;
}
6 changes: 3 additions & 3 deletions src/h264fileparser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include "stream.hpp"

class H264FileParser : public StreamSource{
// std::optional<std::vector<std::byte>> previousUnitType5 = std::nullopt;
// std::optional<std::vector<std::byte>> previousUnitType7 = std::nullopt;
// std::optional<std::vector<std::byte>> previousUnitType8 = std::nullopt;
std::optional<std::vector<std::byte>> previousUnitType5 = std::nullopt;
std::optional<std::vector<std::byte>> previousUnitType7 = std::nullopt;
std::optional<std::vector<std::byte>> previousUnitType8 = std::nullopt;

public:
void start() override;
Expand Down
2 changes: 1 addition & 1 deletion src/rtc_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ shared_ptr<Client> RtcPublisher::createPeerConnection(const Configuration &confi
shared_ptr<Stream> RtcPublisher::createStream(const unsigned int fps) {
auto stream = make_shared<Stream>(video);
// set callback responsible for sample sending
std::cout<<"new stream created"<<std::endl;
stream->onSample([this,ws = make_weak_ptr(stream)](Stream::StreamSourceType type, uint64_t sampleTime, rtc::binary sample) {
vector<ClientTrack> tracks{};
string streamType = type == Stream::StreamSourceType::Video ? "video" : "audio";
Expand All @@ -142,7 +143,6 @@ shared_ptr<Stream> RtcPublisher::createStream(const unsigned int fps) {
tracks.push_back(ClientTrack(id, trackData));
}
}
std::cout<<"I am here"<<std::endl;
if (!tracks.empty()) {
for (auto clientTrack: tracks) {
auto client = clientTrack.id;
Expand Down
2 changes: 0 additions & 2 deletions src/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,9 @@ void Stream::publishSample() {
if(!isRunning)
return;
auto ssSST = unsafePrepareForSample();
printf("hello world\n");
auto ss = ssSST.first;
auto sst = ssSST.second;
auto sample = ss->getSample();
printf("h2\n");
sampleHandler(sst,ss->getSampleTime_us(),sample);
}

Expand Down

0 comments on commit bc77c84

Please sign in to comment.