Skip to content

Commit

Permalink
fix remote participant
Browse files Browse the repository at this point in the history
  • Loading branch information
lastpeony committed Jul 31, 2024
1 parent cbe7e25 commit 8c9c5a6
Show file tree
Hide file tree
Showing 8 changed files with 225 additions and 91 deletions.
91 changes: 73 additions & 18 deletions multitrack-conference-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def init(self, is_headless):
dc = DesiredCapabilities.CHROME.copy()
dc['goog:loggingPrefs'] = { 'browser':'ALL' }

service = Service(executable_path='/home/ubuntu/chromedriver')
#service = Service(executable_path='C:/WebDriver/chromedriver.exe')
service = Service(executable_path='/home/ubuntu/chromedriver')
#service = Service(executable_path='C:/Users/yunus/Desktop/antmedia/chromedriver-win64/chromedriver.exe')


self.driver = webdriver.Chrome(service=service, options=browser_options)

Expand Down Expand Up @@ -72,55 +73,109 @@ def close_all(self):
self.driver.switch_to.window(handle)
self.driver.close()

serverUrl="https://test.antmedia.io:5443/"
appName="LiveApp/"

url="https://test.antmedia.io:5443/LiveApp/conference.html"
#url="www.google.com"
app = Flask(__name__)
chrome = Browser()
chrome.init(True)


@app.route('/create', methods=['GET'])
def create():
@app.route('/createConference', methods=['GET'])
def createConference():
print("create request came")
url = serverUrl + appName + "conference.html"
room = request.args.get('room')
test = request.args.get('test')
participant = request.args.get('participant')
print("\n create for room:"+room+":"+participant+" in "+test)
print("\n create for room:"+room+":"+participant+" in "+test)
chrome.open_in_new_tab(url+"?roomId="+room+"&streamId="+participant, participant)
return f'Room created', 200

@app.route('/join', methods=['GET'])
def join():
@app.route('/joinConference', methods=['GET'])
def joinConference():
print("join request came")
room = request.args.get('room')
test = request.args.get('test')
participant = request.args.get('participant')
print("\n join for room:"+room+":"+participant+" in "+test)
chrome.switch_to_tab(participant)
chrome.switch_to_tab(participant)
join_button = chrome.get_element_by_id("join_publish_button")
join_button.click()
return f'Joined the room', 200

@app.route('/leave', methods=['GET'])
def leave():
@app.route('/leaveConference', methods=['GET'])
def leaveConference():
print("leave request came")
room = request.args.get('room')
test = request.args.get('test')
participant = request.args.get('participant')
print("\n leave for room:"+room+":"+participant+" in "+test)
chrome.switch_to_tab(participant)
print("\n leave for room:"+room+":"+participant+" in "+test)
chrome.switch_to_tab(participant)
leave_button = chrome.get_element_by_id("stop_publish_button")
leave_button.click()
return f'Left the room', 200

@app.route('/delete', methods=['GET'])
def delete():
@app.route('/deleteConference', methods=['GET'])
def deleteConference():
print("delete request came")
room = request.args.get('room')
test = request.args.get('test')
participant = request.args.get('participant')
print("\n delete for room:"+room+":"+participant+" in "+test)
chrome.switch_to_tab(participant)
print("\n delete for room:"+room+":"+participant+" in "+test)
chrome.switch_to_tab(participant)
chrome.close()
return f'Tab closed', 200


@app.route('/createP2P', methods=['GET'])
def createP2P():
print("create p2p request came")
url = serverUrl + appName + "peer.html"
streamName = request.args.get('streamName')
test = request.args.get('test')
print("\n create p2p for streamName:"+streamName+" in "+test)
chrome.open_in_new_tab(url, streamName)
streamNameInput = chrome.find_element_by_id('streamName')
streamNameInput.clear()
streamNameInput.send_keys(streamName)

return f'P2P created', 200

@app.route('/joinP2P', methods=['GET'])
def joinP2P():
print("join p2p request came")
streamName = request.args.get('streamName')
test = request.args.get('test')
print("\n join P2P for stream name:"+streamName+" in "+test)
chrome.switch_to_tab(streamName)
join_button = chrome.get_element_by_id("join_button")
join_button.click()
return f'Joined P2P', 200

@app.route('/leaveP2P', methods=['GET'])
def leaveP2P():
print("leave p2p request came")
streamName = request.args.get('streamName')
test = request.args.get('test')
print("\n leave P2P for stream name:"+streamName+" in "+test)
chrome.switch_to_tab(streamName)
leave_button = chrome.get_element_by_id("leave_button")
leave_button.click()
return f'Left the room', 200

@app.route('/deleteP2P', methods=['GET'])
def deleteP2P():
print("delete request came")
streamName = request.args.get('streamName')
test = request.args.get('test')
streamName = request.args.get('streamName')
print("\n delete P2P for stream name:"+streamName+" in "+test)
chrome.switch_to_tab(streamName)
chrome.close()
return f'P2P Tab closed', 200



if __name__ == '__main__':
app.run(host='0.0.0.0', port=3030)
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void publish(String streamId, String token, boolean videoCallEnabled, boolean au
/**
* Sets quality of a stream/subtrack to certain resolution.
* @param mainTrackStreamId : If its a single stream pass its streamId as mainTrackId. If you want to change resolution of a subtrack, pass mainTrack stream Id and subtrack stream Id.
* @param subTrackStreamId : If you want to change resolution of subtrack, pass its subTrack stream Id. If you dont want to change subtrack resolution pass null or empty str.
* @param subTrackStreamId : If you want to change resolution of sub track, pass its subTrack stream Id. If you dont want to change subtrack resolution pass null or empty str.
* @param resolutionHeight: The height to be forced. If you set the height to zero, it will become auto. example: For 720p pass 720 as resolution.
*/
void forceStreamQuality(String mainTrackStreamId, String subTrackStreamId, int resolutionHeight);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ public interface IWebRTCListener {
*/
void onStreamInfoList(String streamId, ArrayList<StreamInfo> streamInfoList);

/**
* It's called when a new video track is added.
*
* @param track
* @param trackId
* @return
*/
void onNewVideoTrack(VideoTrack track);

/**
* It's called when a new video track is added.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1321,11 +1321,16 @@ public void onIceDisconnected(String streamId) {
if (config.webRTCListener != null) {
config.webRTCListener.onIceDisconnected(streamId);
}

if (streamStoppedByUser) {
release(true);
return;
}

if(streamId.equals(roomId)){
return;
}

if (config.reconnectionEnabled) {
rePublishPlay();
}
Expand Down
Loading

0 comments on commit 8c9c5a6

Please sign in to comment.