{"action":"created","comment":{"url":"https://api.github.com/repos/pions/webrtc/pulls/comments/230265167","pull_request_review_id":170964460,"id":230265167,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMDI2NTE2Nw==","diff_hunk":"@@ -956,31 +955,46 @@ func (pc *RTCPeerConnection) NewRTCTrack(payloadType uint8, id, label string) (*\n \t\treturn nil, errors.New(\"codec payloader not set\")\n \t}\n \n-\tbuf := make([]byte, 4)\n-\t_, err = rand.Read(buf)\n-\tif err != nil {\n-\t\treturn nil, errors.New(\"failed to generate random value\")\n-\t}\n-\n \ttrackInput := make(chan media.RTCSample, 15) // Is the buffering needed?\n-\tssrc := binary.LittleEndian.Uint32(buf)\n-\tgo func() {\n-\t\tpacketizer := rtp.NewPacketizer(\n-\t\t\t1400,\n-\t\t\tpayloadType,\n-\t\t\tssrc,\n-\t\t\tcodec.Payloader,\n-\t\t\trtp.NewRandomSequencer(),\n-\t\t\tcodec.ClockRate,\n-\t\t)\n-\t\tfor {\n-\t\t\tin := <-trackInput\n-\t\t\tpackets := packetizer.Packetize(in.Data, in.Samples)\n-\t\t\tfor _, p := range packets {\n+\trawPackets := make(chan *rtp.Packet)\n+\tif ssrc == 0 {\n+\t\tbuf := make([]byte, 4)\n+\t\t_, err = rand.Read(buf)\n+\t\tif err != nil {\n+\t\t\treturn nil, errors.New(\"failed to generate random value\")\n+\t\t}\n+\t\tssrc = binary.LittleEndian.Uint32(buf)\n+\n+\t\tgo func() {\n+\t\t\tpacketizer := rtp.NewPacketizer(\n+\t\t\t\t1400,\n+\t\t\t\tpayloadType,\n+\t\t\t\tssrc,\n+\t\t\t\tcodec.Payloader,\n+\t\t\t\trtp.NewRandomSequencer(),\n+\t\t\t\tcodec.ClockRate,\n+\t\t\t)\n+\n+\t\t\tfor {\n+\t\t\t\tin := <-trackInput\n+\t\t\t\tpackets := packetizer.Packetize(in.Data, in.Samples)\n+\t\t\t\tfor _, p := range packets {\n+\t\t\t\t\tpc.networkManager.SendRTP(p)\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}()\n+\t\tclose(rawPackets)\n+\t} else {\n+\t\t// If SSRC is not 0, then we are working with an established RTP stream\n+\t\t// and need to accept raw RTP packets for forwarding.\n+\t\tgo func() {\n+\t\t\tfor {\n+\t\t\t\tp := <-rawPackets","path":"rtcpeerconnection.go","position":68,"original_position":68,"commit_id":"1db1f75542b5240ba7166f1e0bd0ab92555466f2","original_commit_id":"1db1f75542b5240ba7166f1e0bd0ab92555466f2","user":{"login":"Sean-Der","id":1302304,"node_id":"MDQ6VXNlcjEzMDIzMDQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1302304?v=4","gravatar_id":"","url":"https://api.github.com/users/Sean-Der","html_url":"https://github.com/Sean-Der","followers_url":"https://api.github.com/users/Sean-Der/followers","following_url":"https://api.github.com/users/Sean-Der/following{/other_user}","gists_url":"https://api.github.com/users/Sean-Der/gists{/gist_id}","starred_url":"https://api.github.com/users/Sean-Der/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sean-Der/subscriptions","organizations_url":"https://api.github.com/users/Sean-Der/orgs","repos_url":"https://api.github.com/users/Sean-Der/repos","events_url":"https://api.github.com/users/Sean-Der/events{/privacy}","received_events_url":"https://api.github.com/users/Sean-Der/received_events","type":"User","site_admin":false},"body":"Can/should we copy the packets here?\r\n\r\nIt may confuse users if they try to send the same packet twice, it will become corrupted (because later we encrypt in place)","created_at":"2018-11-02T04:06:21Z","updated_at":"2018-11-02T04:06:22Z","html_url":"https://github.com/pions/webrtc/pull/213#discussion_r230265167","pull_request_url":"https://api.github.com/repos/pions/webrtc/pulls/213","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pions/webrtc/pulls/comments/230265167"},"html":{"href":"https://github.com/pions/webrtc/pull/213#discussion_r230265167"},"pull_request":{"href":"https://api.github.com/repos/pions/webrtc/pulls/213"}}},"pull_request":{"url":"https://api.github.com/repos/pions/webrtc/pulls/213","id":227740023,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI3NzQwMDIz","html_url":"https://github.com/pions/webrtc/pull/213","diff_url":"https://github.com/pions/webrtc/pull/213.diff","patch_url":"https://github.com/pions/webrtc/pull/213.patch","issue_url":"https://api.github.com/repos/pions/webrtc/issues/213","number":213,"state":"open","locked":false,"title":"Allow Raw RTP input to RTCTrack","user":{"login":"mjmac","id":83737,"node_id":"MDQ6VXNlcjgzNzM3","avatar_url":"https://avatars1.githubusercontent.com/u/83737?v=4","gravatar_id":"","url":"https://api.github.com/users/mjmac","html_url":"https://github.com/mjmac","followers_url":"https://api.github.com/users/mjmac/followers","following_url":"https://api.github.com/users/mjmac/following{/other_user}","gists_url":"https://api.github.com/users/mjmac/gists{/gist_id}","starred_url":"https://api.github.com/users/mjmac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjmac/subscriptions","organizations_url":"https://api.github.com/users/mjmac/orgs","repos_url":"https://api.github.com/users/mjmac/repos","events_url":"https://api.github.com/users/mjmac/events{/privacy}","received_events_url":"https://api.github.com/users/mjmac/received_events","type":"User","site_admin":false},"body":"Resolves #212\r\n\r\nSupport forwarding packets from existing RTP streams. Adds\r\nthe following new methods to RTCPeerConnection:\r\n  * NewRawRTPTrack() -- expects a non-zero SSRC and accepts\r\n    a stream of *rtp.Packet from an existing RTP stream\r\n  * NewRTCSampleTrack() -- generates an SSRC and accepts\r\n    a stream of media.RTCSample\r\n\r\nDeprecates NewRTCTrack() in favor of NewRTCSampleTrack().\r\n\r\nExposes a new RawRTP channel on *RTCTrack instances which\r\naccepts *rtp.Packet.","created_at":"2018-11-01T19:56:58Z","updated_at":"2018-11-02T04:06:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"05804ba41da8145812c98334c7cc59f2f80d7495","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pions/webrtc/pulls/213/commits","review_comments_url":"https://api.github.com/repos/pions/webrtc/pulls/213/comments","review_comment_url":"https://api.github.com/repos/pions/webrtc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pions/webrtc/issues/213/comments","statuses_url":"https://api.github.com/repos/pions/webrtc/statuses/1db1f75542b5240ba7166f1e0bd0ab92555466f2","head":{"label":"mjmac:rawrtp","ref":"rawrtp","sha":"1db1f75542b5240ba7166f1e0bd0ab92555466f2","user":{"login":"mjmac","id":83737,"node_id":"MDQ6VXNlcjgzNzM3","avatar_url":"https://avatars1.githubusercontent.com/u/83737?v=4","gravatar_id":"","url":"https://api.github.com/users/mjmac","html_url":"https://github.com/mjmac","followers_url":"https://api.github.com/users/mjmac/followers","following_url":"https://api.github.com/users/mjmac/following{/other_user}","gists_url":"https://api.github.com/users/mjmac/gists{/gist_id}","starred_url":"https://api.github.com/users/mjmac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjmac/subscriptions","organizations_url":"https://api.github.com/users/mjmac/orgs","repos_url":"https://api.github.com/users/mjmac/repos","events_url":"https://api.github.com/users/mjmac/events{/privacy}","received_events_url":"https://api.github.com/users/mjmac/received_events","type":"User","site_admin":false},"repo":{"id":155753196,"node_id":"MDEwOlJlcG9zaXRvcnkxNTU3NTMxOTY=","name":"webrtc","full_name":"mjmac/webrtc","private":false,"owner":{"login":"mjmac","id":83737,"node_id":"MDQ6VXNlcjgzNzM3","avatar_url":"https://avatars1.githubusercontent.com/u/83737?v=4","gravatar_id":"","url":"https://api.github.com/users/mjmac","html_url":"https://github.com/mjmac","followers_url":"https://api.github.com/users/mjmac/followers","following_url":"https://api.github.com/users/mjmac/following{/other_user}","gists_url":"https://api.github.com/users/mjmac/gists{/gist_id}","starred_url":"https://api.github.com/users/mjmac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjmac/subscriptions","organizations_url":"https://api.github.com/users/mjmac/orgs","repos_url":"https://api.github.com/users/mjmac/repos","events_url":"https://api.github.com/users/mjmac/events{/privacy}","received_events_url":"https://api.github.com/users/mjmac/received_events","type":"User","site_admin":false},"html_url":"https://github.com/mjmac/webrtc","description":"A pure Golang implementation of the WebRTC Native API","fork":true,"url":"https://api.github.com/repos/mjmac/webrtc","forks_url":"https://api.github.com/repos/mjmac/webrtc/forks","keys_url":"https://api.github.com/repos/mjmac/webrtc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mjmac/webrtc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mjmac/webrtc/teams","hooks_url":"https://api.github.com/repos/mjmac/webrtc/hooks","issue_events_url":"https://api.github.com/repos/mjmac/webrtc/issues/events{/number}","events_url":"https://api.github.com/repos/mjmac/webrtc/events","assignees_url":"https://api.github.com/repos/mjmac/webrtc/assignees{/user}","branches_url":"https://api.github.com/repos/mjmac/webrtc/branches{/branch}","tags_url":"https://api.github.com/repos/mjmac/webrtc/tags","blobs_url":"https://api.github.com/repos/mjmac/webrtc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mjmac/webrtc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mjmac/webrtc/git/refs{/sha}","trees_url":"https://api.github.com/repos/mjmac/webrtc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mjmac/webrtc/statuses/{sha}","languages_url":"https://api.github.com/repos/mjmac/webrtc/languages","stargazers_url":"https://api.github.com/repos/mjmac/webrtc/stargazers","contributors_url":"https://api.github.com/repos/mjmac/webrtc/contributors","subscribers_url":"https://api.github.com/repos/mjmac/webrtc/subscribers","subscription_url":"https://api.github.com/repos/mjmac/webrtc/subscription","commits_url":"https://api.github.com/repos/mjmac/webrtc/commits{/sha}","git_commits_url":"https://api.github.com/repos/mjmac/webrtc/git/commits{/sha}","comments_url":"https://api.github.com/repos/mjmac/webrtc/comments{/number}","issue_comment_url":"https://api.github.com/repos/mjmac/webrtc/issues/comments{/number}","contents_url":"https://api.github.com/repos/mjmac/webrtc/contents/{+path}","compare_url":"https://api.github.com/repos/mjmac/webrtc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mjmac/webrtc/merges","archive_url":"https://api.github.com/repos/mjmac/webrtc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mjmac/webrtc/downloads","issues_url":"https://api.github.com/repos/mjmac/webrtc/issues{/number}","pulls_url":"https://api.github.com/repos/mjmac/webrtc/pulls{/number}","milestones_url":"https://api.github.com/repos/mjmac/webrtc/milestones{/number}","notifications_url":"https://api.github.com/repos/mjmac/webrtc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mjmac/webrtc/labels{/name}","releases_url":"https://api.github.com/repos/mjmac/webrtc/releases{/id}","deployments_url":"https://api.github.com/repos/mjmac/webrtc/deployments","created_at":"2018-11-01T17:43:08Z","updated_at":"2018-11-01T17:43:10Z","pushed_at":"2018-11-01T20:36:24Z","git_url":"git://github.com/mjmac/webrtc.git","ssh_url":"git@github.com:mjmac/webrtc.git","clone_url":"https://github.com/mjmac/webrtc.git","svn_url":"https://github.com/mjmac/webrtc","homepage":null,"size":835,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pions:master","ref":"master","sha":"163bc1351360c8688bf5fd1ac78371e0dbbc16e3","user":{"login":"pions","id":38192892,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4MTkyODky","avatar_url":"https://avatars2.githubusercontent.com/u/38192892?v=4","gravatar_id":"","url":"https://api.github.com/users/pions","html_url":"https://github.com/pions","followers_url":"https://api.github.com/users/pions/followers","following_url":"https://api.github.com/users/pions/following{/other_user}","gists_url":"https://api.github.com/users/pions/gists{/gist_id}","starred_url":"https://api.github.com/users/pions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pions/subscriptions","organizations_url":"https://api.github.com/users/pions/orgs","repos_url":"https://api.github.com/users/pions/repos","events_url":"https://api.github.com/users/pions/events{/privacy}","received_events_url":"https://api.github.com/users/pions/received_events","type":"Organization","site_admin":false},"repo":{"id":134012064,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQwMTIwNjQ=","name":"webrtc","full_name":"pions/webrtc","private":false,"owner":{"login":"pions","id":38192892,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4MTkyODky","avatar_url":"https://avatars2.githubusercontent.com/u/38192892?v=4","gravatar_id":"","url":"https://api.github.com/users/pions","html_url":"https://github.com/pions","followers_url":"https://api.github.com/users/pions/followers","following_url":"https://api.github.com/users/pions/following{/other_user}","gists_url":"https://api.github.com/users/pions/gists{/gist_id}","starred_url":"https://api.github.com/users/pions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pions/subscriptions","organizations_url":"https://api.github.com/users/pions/orgs","repos_url":"https://api.github.com/users/pions/repos","events_url":"https://api.github.com/users/pions/events{/privacy}","received_events_url":"https://api.github.com/users/pions/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/pions/webrtc","description":"A pure Golang implementation of the WebRTC Native API","fork":false,"url":"https://api.github.com/repos/pions/webrtc","forks_url":"https://api.github.com/repos/pions/webrtc/forks","keys_url":"https://api.github.com/repos/pions/webrtc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pions/webrtc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pions/webrtc/teams","hooks_url":"https://api.github.com/repos/pions/webrtc/hooks","issue_events_url":"https://api.github.com/repos/pions/webrtc/issues/events{/number}","events_url":"https://api.github.com/repos/pions/webrtc/events","assignees_url":"https://api.github.com/repos/pions/webrtc/assignees{/user}","branches_url":"https://api.github.com/repos/pions/webrtc/branches{/branch}","tags_url":"https://api.github.com/repos/pions/webrtc/tags","blobs_url":"https://api.github.com/repos/pions/webrtc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pions/webrtc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pions/webrtc/git/refs{/sha}","trees_url":"https://api.github.com/repos/pions/webrtc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pions/webrtc/statuses/{sha}","languages_url":"https://api.github.com/repos/pions/webrtc/languages","stargazers_url":"https://api.github.com/repos/pions/webrtc/stargazers","contributors_url":"https://api.github.com/repos/pions/webrtc/contributors","subscribers_url":"https://api.github.com/repos/pions/webrtc/subscribers","subscription_url":"https://api.github.com/repos/pions/webrtc/subscription","commits_url":"https://api.github.com/repos/pions/webrtc/commits{/sha}","git_commits_url":"https://api.github.com/repos/pions/webrtc/git/commits{/sha}","comments_url":"https://api.github.com/repos/pions/webrtc/comments{/number}","issue_comment_url":"https://api.github.com/repos/pions/webrtc/issues/comments{/number}","contents_url":"https://api.github.com/repos/pions/webrtc/contents/{+path}","compare_url":"https://api.github.com/repos/pions/webrtc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pions/webrtc/merges","archive_url":"https://api.github.com/repos/pions/webrtc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pions/webrtc/downloads","issues_url":"https://api.github.com/repos/pions/webrtc/issues{/number}","pulls_url":"https://api.github.com/repos/pions/webrtc/pulls{/number}","milestones_url":"https://api.github.com/repos/pions/webrtc/milestones{/number}","notifications_url":"https://api.github.com/repos/pions/webrtc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pions/webrtc/labels{/name}","releases_url":"https://api.github.com/repos/pions/webrtc/releases{/id}","deployments_url":"https://api.github.com/repos/pions/webrtc/deployments","created_at":"2018-05-18T23:10:05Z","updated_at":"2018-11-01T06:47:40Z","pushed_at":"2018-11-01T20:36:25Z","git_url":"git://github.com/pions/webrtc.git","ssh_url":"git@github.com:pions/webrtc.git","clone_url":"https://github.com/pions/webrtc.git","svn_url":"https://github.com/pions/webrtc","homepage":null,"size":828,"stargazers_count":645,"watchers_count":645,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":68,"mirror_url":null,"archived":false,"open_issues_count":46,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":68,"open_issues":46,"watchers":645,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pions/webrtc/pulls/213"},"html":{"href":"https://github.com/pions/webrtc/pull/213"},"issue":{"href":"https://api.github.com/repos/pions/webrtc/issues/213"},"comments":{"href":"https://api.github.com/repos/pions/webrtc/issues/213/comments"},"review_comments":{"href":"https://api.github.com/repos/pions/webrtc/pulls/213/comments"},"review_comment":{"href":"https://api.github.com/repos/pions/webrtc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pions/webrtc/pulls/213/commits"},"statuses":{"href":"https://api.github.com/repos/pions/webrtc/statuses/1db1f75542b5240ba7166f1e0bd0ab92555466f2"}},"author_association":"NONE"}}
{"actor":{"display_login":"Sean-Der"}}