Commit 5d90c3bc authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

media: link to avModel

Change-Id: I0a904813749d3ddc645878fad107aacdee9cd9bc
parent 8ba71157
......@@ -21,6 +21,7 @@
#import "RingWindowController.h"
#import "PreferencesWindowController.h"
#import <string>
@interface AppDelegate : NSObject <NSApplicationDelegate, NSUserNotificationCenterDelegate>
......@@ -28,5 +29,6 @@
- (void) showMainWindow;
- (void) showDialpad;
- (BOOL) checkForRingAccount;
- (std::vector<std::string>) getActiveCalls;
@end
......@@ -350,6 +350,9 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet
[self.dialpad.window makeKeyAndOrderFront:self];
}
-(std::vector<std::string>) getActiveCalls {
return lrc->activeCalls();
}
- (BOOL) checkForRingAccount
{
......@@ -364,39 +367,6 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet
forEventClass:kInternetEventClass andEventID:kAEGetURL];
}
/**
* Recognized patterns:
* - ring:<hash>
* - ring://<hash>
*/
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
NSString* query = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
NSURL* url = [[NSURL alloc] initWithString:query];
NSString* ringID = [url host];
if (!ringID) {
//not a valid NSURL, try to parse query directly
ringID = [query substringFromIndex:@"ring:".length];
}
// check for a valid ring hash
NSCharacterSet *hexSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789abcdefABCDEF"];
BOOL valid = [[ringID stringByTrimmingCharactersInSet:hexSet] isEqualToString:@""];
if(valid && ringID.length == 40) {
Call* c = CallModel::instance().dialingCall();
c->setDialNumber(QString::fromNSString([NSString stringWithFormat:@"ring:%@",ringID]));
c << Call::Action::ACCEPT;
} else {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
[alert setMessageText:@"Error"];
[alert setInformativeText:@"ringID cannot be read from this URL."];
[alert setAlertStyle:NSWarningAlertStyle];
[alert runModal];
}
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
{
if([self checkForRingAccount]) {
......
......@@ -18,8 +18,9 @@
*/
#import <Cocoa/Cocoa.h>
#import "LrcModelsProtocol.h"
@interface AudioPrefsVC : NSViewController <NSMenuDelegate, NSPathControlDelegate, NSOpenSavePanelDelegate> {
@interface AudioPrefsVC : NSViewController <LrcModelsProtocol> {
}
......
/*
* Copyright (C) 2015-2016 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
* Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -18,203 +19,73 @@
*/
#import "AudioPrefsVC.h"
#import <audio/settings.h>
#import <media/recordingmodel.h>
#import <QUrl>
#import <audio/inputdevicemodel.h>
#import <audio/outputdevicemodel.h>
#import <qitemselectionmodel.h>
#import "utils.h"
//LRC
#import <api/avmodel.h>
@interface AudioPrefsVC ()
@property (assign) IBOutlet NSPathControl *recordingsPathControl;
@property (assign) IBOutlet NSPopUpButton *outputDeviceList;
@property (assign) IBOutlet NSPopUpButton *inputDeviceList;
@property (assign) IBOutlet NSButton *alwaysRecordingButton;
@property (assign) IBOutlet NSButton *muteDTMFButton;
@property (assign) IBOutlet NSTextField *recordingHeaderTitle;
@property (assign) IBOutlet NSTextField *recordingpathLabel;
@property (assign) IBOutlet NSLayoutConstraint* audioMarginTopConstraint;
@property (assign) IBOutlet NSLayoutConstraint* audioMarginBottomConstraint;
@end
@implementation AudioPrefsVC
@synthesize recordingsPathControl, recordingHeaderTitle, recordingpathLabel;
@synthesize outputDeviceList;
@synthesize inputDeviceList;
@synthesize alwaysRecordingButton;
@synthesize muteDTMFButton;
@synthesize audioMarginTopConstraint, audioMarginBottomConstraint;
@synthesize avModel;
QMetaObject::Connection audioDeviceEvent;
- (void)loadView
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil avModel:(lrc::api::AVModel*) avModel
{
[super loadView];
QModelIndex qInputIdx = Audio::Settings::instance().inputDeviceModel()->selectionModel()->currentIndex();
QModelIndex qOutputIdx = Audio::Settings::instance().outputDeviceModel()->selectionModel()->currentIndex();
[self.outputDeviceList addItemWithTitle:
Audio::Settings::instance().outputDeviceModel()->data(qOutputIdx, Qt::DisplayRole).toString().toNSString()];
[self.inputDeviceList addItemWithTitle:
Audio::Settings::instance().inputDeviceModel()->data(qInputIdx, Qt::DisplayRole).toString().toNSString()];
[self.alwaysRecordingButton setState:
media::RecordingModel::instance().isAlwaysRecording() ? NSOnState:NSOffState];
[self.muteDTMFButton setState:
Audio::Settings::instance().areDTMFMuted()?NSOnState:NSOffState];
NSArray* pathComponentArray = [self pathComponentArrayWithCurrentUrl:media::RecordingModel::instance().recordPath().toNSString()];
[recordingsPathControl setPathComponentCells:pathComponentArray];
if (appSandboxed()) {
[alwaysRecordingButton setHidden:YES];
[recordingsPathControl setEnabled:NO];
[recordingsPathControl setHidden: YES];
[recordingHeaderTitle setHidden: YES];
[recordingpathLabel setHidden: YES];
audioMarginTopConstraint.constant = 10.0f;
audioMarginBottomConstraint.constant = 67.0f;
if (self = [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
self.avModel = avModel;
}
return self;
}
- (IBAction)toggleMuteDTMF:(NSButton *)sender
- (void)loadView
{
Audio::Settings::instance().setDTMFMuted([sender state] == NSOnState);
[super loadView];
[self connectdDeviceEvent];
[self addDevices];
}
- (IBAction)toggleAlwaysRecording:(NSButton *)sender
{
media::RecordingModel::instance().setAlwaysRecording([sender state] == NSOnState);
-(void) addDevices {
[inputDeviceList removeAllItems];
[outputDeviceList removeAllItems];
auto inputDevices = avModel->getAudioInputDevices();
auto inputDevice = avModel->getInputDevice();
for (auto device : inputDevices) {
[inputDeviceList addItemWithTitle: @(device.c_str())];
}
[inputDeviceList selectItemWithTitle:@(inputDevice.c_str())];
auto outputDevices = avModel->getAudioOutputDevices();
auto outputDevice = avModel->getOutputDevice();
for (auto device : outputDevices) {
[outputDeviceList addItemWithTitle: @(device.c_str())];
}
[outputDeviceList selectItemWithTitle:@(outputDevice.c_str())];
}
- (IBAction)pathControlSingleClick:(id)sender {
// Select that chosen component of the path.
NSArray* pathComponentArray = [self pathComponentArrayWithCurrentUrl:[[self.recordingsPathControl clickedPathComponentCell] URL].path];
[recordingsPathControl setPathComponentCells:pathComponentArray];
media::RecordingModel::instance().setRecordPath(QString::fromNSString([self.recordingsPathControl.URL path]));
-(void)connectdDeviceEvent {
QObject::disconnect(audioDeviceEvent);
audioDeviceEvent = QObject::connect(avModel,
&lrc::api::AVModel::deviceEvent,
[=]() {
[self addDevices];
});
}
- (IBAction)chooseOutput:(id)sender {
int index = [sender indexOfSelectedItem];
QModelIndex qIdx = Audio::Settings::instance().outputDeviceModel()->index(index, 0);
Audio::Settings::instance().outputDeviceModel()->selectionModel()->setCurrentIndex(
qIdx, QItemSelectionModel::ClearAndSelect);
auto output = [self.outputDeviceList itemTitleAtIndex:index];
avModel->setOutputDevice([output UTF8String]);
}
- (IBAction)chooseInput:(id)sender {
int index = [sender indexOfSelectedItem];
QModelIndex qIdx = Audio::Settings::instance().inputDeviceModel()->index(index, 0);
Audio::Settings::instance().inputDeviceModel()->selectionModel()->setCurrentIndex(
qIdx, QItemSelectionModel::ClearAndSelect);
}
#pragma mark - NSPathControl delegate methods
/*
Assemble a set of custom cells to display into an array to pass to the path control.
*/
- (NSArray *)pathComponentArrayWithCurrentUrl:(NSString *) url
{
NSMutableArray *pathComponentArray = [[NSMutableArray alloc] init];
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSURL* downloadURL = [fileManager URLForDirectory:NSDownloadsDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
NSPathComponentCell *componentCell;
componentCell = [self componentCellForType:kGenericFolderIcon withTitle:@"Downloads" URL:downloadURL];
[pathComponentArray addObject:componentCell];
NSString * downloads = [downloadURL path];
if([url isEqualToString:downloads]) {
return pathComponentArray;
}
if(![url isEqualToString:@""]) {
NSString * name = [url componentsSeparatedByString:@"/"].lastObject;
if(!name) {
return pathComponentArray;
}
componentCell = [self componentCellForType:kGenericFolderIcon withTitle:name URL:[NSURL URLWithString: url]];
[pathComponentArray addObject:componentCell];
}
return pathComponentArray;
}
/*
This method is used by pathComponentArray to create a NSPathComponent cell based on icon, title and URL information.
Each path component needs an icon, URL and title.
*/
- (NSPathComponentCell *)componentCellForType:(OSType)withIconType withTitle:(NSString *)title URL:(NSURL *)url
{
NSPathComponentCell *componentCell = [[NSPathComponentCell alloc] init];
NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(withIconType)];
[componentCell setImage:iconImage];
[componentCell setURL:url];
[componentCell setTitle:title];
return componentCell;
}
/*
Delegate method of NSPathControl to determine how the NSOpenPanel will look/behave.
*/
- (void)pathControl:(NSPathControl *)pathControl willDisplayOpenPanel:(NSOpenPanel *)openPanel
{
NSLog(@"willDisplayOpenPanel");
[openPanel setAllowsMultipleSelection:NO];
[openPanel setCanChooseDirectories:YES];
[openPanel setCanChooseFiles:NO];
[openPanel setResolvesAliases:YES];
[openPanel setTitle:NSLocalizedString(@"Choose a directory", @"Open panel title")];
[openPanel setPrompt:NSLocalizedString(@"Choose directory", @"Open panel prompt for 'Choose a directory'")];
[openPanel setDelegate:self];
}
- (void)pathControl:(NSPathControl *)pathControl willPopUpMenu:(NSMenu *)menu
{
}
#pragma mark - NSOpenSavePanelDelegate delegate methods
- (BOOL)panel:(id)sender validateURL:(NSURL *)url error:(NSError **)outError
{
[recordingsPathControl setURL:url];
return YES;
}
- (BOOL) panel:(id)sender shouldEnableURL:(NSURL*)url {
return YES;
}
#pragma mark - NSMenuDelegate methods
- (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)item atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel
{
QModelIndex qIdx;
if (inputDeviceList.menu == menu) {
qIdx = Audio::Settings::instance().inputDeviceModel()->index(index);
[item setTitle:Audio::Settings::instance().inputDeviceModel()->data(qIdx, Qt::DisplayRole).toString().toNSString()];
} else {
qIdx = Audio::Settings::instance().outputDeviceModel()->index(index);
[item setTitle:Audio::Settings::instance().outputDeviceModel()->data(qIdx, Qt::DisplayRole).toString().toNSString()];
}
return YES;
}
- (NSInteger)numberOfItemsInMenu:(NSMenu *)menu
{
if (inputDeviceList.menu == menu)
return Audio::Settings::instance().inputDeviceModel()->rowCount();
else
return Audio::Settings::instance().outputDeviceModel()->rowCount();
auto input = [self.inputDeviceList itemTitleAtIndex:index];
avModel->setInputDevice([input UTF8String]);
}
@end
......@@ -23,6 +23,12 @@
#import "views/CallView.h"
#import <api/account.h>
namespace lrc {
namespace api {
class AVModel;
}
}
@protocol CallViewControllerDelegate
-(void) conversationInfoUpdatedFor:(const std::string&) conversationID;
......@@ -39,5 +45,6 @@
-(void) hideWithAnimation:(BOOL)animate;
-(void) setCurrentCall:(const std::string&)callUid
conversation:(const std::string&)convUid
account:(const lrc::api::account::Info*)account;
account:(const lrc::api::account::Info*)account
avModel:(lrc::api::AVModel *)avModel;
@end
......@@ -29,6 +29,7 @@ extern "C" {
#import <QtMacExtras/qmacfunctions.h>
#import <QtCore/qabstractitemmodel.h>
#import <QPixmap>
#import <QUrl>
///LRC
#import <video/previewmanager.h>
......@@ -36,6 +37,7 @@ extern "C" {
#import <api/newcallmodel.h>
#import <api/call.h>
#import <api/conversationmodel.h>
#import <api/avmodel.h>
#import <globalinstances.h>
#import "AppDelegate.h"
......@@ -128,8 +130,7 @@ extern "C" {
@property (unsafe_unretained) IBOutlet CallMTKView *videoMTKView;
@property RendererConnectionsHolder* previewHolder;
@property RendererConnectionsHolder* videoHolder;
@property RendererConnectionsHolder* renderConnections;
@property QMetaObject::Connection videoStarted;
@property QMetaObject::Connection selectedCallChanged;
@property QMetaObject::Connection messageConnection;
......@@ -140,6 +141,7 @@ extern "C" {
@end
@implementation CurrentCallVC
lrc::api::AVModel* mediaModel;
@synthesize personLabel, personPhoto, stateLabel, holdOnOffButton, hangUpButton,
recordOnOffButton, pickUpButton, chatButton, transferButton, addParticipantButton, timeSpentLabel,
muteVideoButton, muteAudioButton, controlsPanel, advancedPanel, advancedButton, headerContainer, videoView,
......@@ -147,8 +149,7 @@ extern "C" {
outgoingPanel, outgoingPersonLabel, outgoingStateLabel, outgoingPhoto, outgoingId,
callRecordButtonMarginLeft, audioCallView, audioCallPhoto, audioCallTime, audioCallPersonLabel, audioCallPersonId, backgroundImage, bluerBackgroundEffect;
@synthesize previewHolder;
@synthesize videoHolder;
@synthesize renderConnections;
CVPixelBufferPoolRef pixelBufferPoolDistantView;
CVPixelBufferRef pixelBufferDistantView;
CVPixelBufferPoolRef pixelBufferPoolPreview;
......@@ -156,11 +157,13 @@ CVPixelBufferRef pixelBufferPreview;
-(void) setCurrentCall:(const std::string&)callUid
conversation:(const std::string&)convUid
account:(const lrc::api::account::Info*)account;
account:(const lrc::api::account::Info*)account
avModel:(lrc::api::AVModel *)avModel;
{
if(account == nil)
return;
mediaModel = avModel;
auto* callModel = account->callModel.get();
if (not callModel->hasCall(callUid)){
......@@ -185,8 +188,7 @@ CVPixelBufferRef pixelBufferPreview;
[controlsPanel.layer setBackgroundColor:[NSColor clearColor].CGColor];
[controlsPanel.layer setFrame:controlsPanel.frame];
previewHolder = [[RendererConnectionsHolder alloc] init];
videoHolder = [[RendererConnectionsHolder alloc] init];
renderConnections = [[RendererConnectionsHolder alloc] init];
[loadingIndicator setColor:[NSColor whiteColor]];
[loadingIndicator setNumberOfLines:200];
......@@ -474,125 +476,89 @@ CVPixelBufferRef pixelBufferPreview;
{
if (accountInfo_ == nil)
return;
auto* callModel = accountInfo_->callModel.get();
QObject::disconnect(self.videoStarted);
self.videoStarted = QObject::connect(callModel,
&lrc::api::NewCallModel::remotePreviewStarted,
[self](const std::string& callId, Video::Renderer* renderer) {
[videoView setShouldAcceptInteractions:YES];
[self.videoMTKView setHidden:NO];
[self mouseIsMoving: NO];
[self connectVideoRenderer:renderer];
});
if (callModel->hasCall(callUid_)) {
if (auto renderer = callModel->getRenderer(callUid_)) {
QObject::disconnect(self.videoStarted);
[self.videoMTKView setHidden:NO];
[self connectVideoRenderer: renderer];
}
}
[self connectPreviewRenderer];
[self connectRenderer];
}
-(void) connectPreviewRenderer
-(void) connectRenderer
{
QObject::disconnect(previewHolder.frameUpdated);
QObject::disconnect(previewHolder.stopped);
QObject::disconnect(previewHolder.started);
previewHolder.started =
QObject::connect(&Video::PreviewManager::instance(),
&Video::PreviewManager::previewStarted,
[=](Video::Renderer* renderer) {
[self.previewView setHidden:NO];
self.previewView.stopRendering = false;
QObject::disconnect(previewHolder.frameUpdated);
previewHolder.frameUpdated =
QObject::connect(renderer,
&Video::Renderer::frameUpdated,
[=]() {
if(!renderer->isRendering()) {
return;
}
[self renderer:renderer renderFrameForPreviewView: self.previewView];
});
});
previewHolder.stopped = QObject::connect(&Video::PreviewManager::instance(),
&Video::PreviewManager::previewStopped,
[=](Video::Renderer* renderer) {
QObject::disconnect(previewHolder.frameUpdated);
[self.previewView setHidden:YES];
self.previewView.stopRendering = true;
});
previewHolder.frameUpdated =
QObject::connect(Video::PreviewManager::instance().previewRenderer(),
&Video::Renderer::frameUpdated,
[=]() {
if(!Video::PreviewManager::instance()
.previewRenderer()->isRendering()) {
return;
QObject::disconnect(renderConnections.frameUpdated);
QObject::disconnect(renderConnections.stopped);
QObject::disconnect(renderConnections.started);
renderConnections.started =
QObject::connect(mediaModel,
&lrc::api::AVModel::rendererStarted,
[=](const std::string& id) {
if (id == lrc::api::video::PREVIEW_RENDERER_ID) {
[self.previewView setHidden:NO];
self.previewView.stopRendering = false;
} else {
[self mouseIsMoving: NO];
self.videoMTKView.stopRendering = false;
[self.videoMTKView setHidden:NO];
[bluerBackgroundEffect setHidden:YES];
[backgroundImage setHidden:YES];
[videoView setShouldAcceptInteractions:YES];
}
[self renderer:Video::PreviewManager::instance()
.previewRenderer() renderFrameForPreviewView: self.previewView];
});
}
-(void) connectVideoRenderer: (Video::Renderer*)renderer
{
QObject::disconnect(videoHolder.frameUpdated);
QObject::disconnect(videoHolder.started);
QObject::disconnect(videoHolder.stopped);
if(renderer == nil)
return;
QObject::disconnect(renderConnections.frameUpdated);
renderConnections.frameUpdated =
QObject::connect(mediaModel,
&lrc::api::AVModel::frameUpdated,
[=](const std::string& id) {
if (id == lrc::api::video::PREVIEW_RENDERER_ID) {
auto renderer = &mediaModel->getRenderer(lrc::api::video::PREVIEW_RENDERER_ID);
if(!renderer->isRendering()) {
return;
}
[self renderer: renderer renderFrameForPreviewView:previewView];
videoHolder.frameUpdated = QObject::connect(renderer,
&Video::Renderer::frameUpdated,
[=]() {
if(!renderer->isRendering()) {
return;
}
[self renderer:renderer renderFrameForDistantView:self.videoMTKView];
} else {
auto renderer = &mediaModel->getRenderer(id);
if(!renderer->isRendering()) {
return;
}
[self renderer:renderer renderFrameForDistantView: self.videoMTKView];
}
});
});
videoHolder.started =
QObject::connect(renderer,
&Video::Renderer::started,
[=]() {
[self mouseIsMoving: NO];
self.videoMTKView.stopRendering = false;
[self.videoMTKView setHidden:NO];
[bluerBackgroundEffect setHidden:YES];
[backgroundImage setHidden:YES];
[videoView setShouldAcceptInteractions:YES];
QObject::disconnect(videoHolder.frameUpdated);
videoHolder.frameUpdated
= QObject::connect(renderer,
&Video::Renderer::frameUpdated,
[=]() {
if(!renderer->isRendering()) {
return;
}
[self renderer:renderer renderFrameForDistantView:self.videoMTKView];
});
renderConnections.stopped =
QObject::connect(mediaModel,
&lrc::api::AVModel::rendererStopped,
[=](const std::string& id) {
QObject::disconnect(renderConnections.frameUpdated);
if (id == lrc::api::video::PREVIEW_RENDERER_ID) {
[self.previewView setHidden:YES];
self.previewView.stopRendering = true;
} else {
[self mouseIsMoving: YES];
self.videoMTKView.stopRendering = true;
[self.videoMTKView setHidden:YES];
[bluerBackgroundEffect setHidden:NO];
[backgroundImage setHidden:NO];
[videoView setShouldAcceptInteractions:NO];
}
});
videoHolder.stopped = QObject::connect(renderer,
&Video::Renderer::stopped,
[=]() {
[self mouseIsMoving: YES];
self.videoMTKView.stopRendering = true;
[self.videoMTKView setHidden:YES];
[bluerBackgroundEffect setHidden:NO];
[backgroundImage setHidden:NO];
[videoView setShouldAcceptInteractions:NO];
QObject::disconnect(videoHolder.frameUpdated);
renderConnections.frameUpdated =
QObject::connect(mediaModel,
&lrc::api::AVModel::frameUpdated,
[=](const std::string& id) {
if (id == lrc::api::video::PREVIEW_RENDERER_ID) {
auto renderer = &mediaModel->getRenderer(lrc::api::video::PREVIEW_RENDERER_ID);
if(!renderer->isRendering()) {
return;
}
[self renderer: renderer renderFrameForPreviewView:previewView];
} else {
auto renderer = &mediaModel->getRenderer(id);
if(!renderer->isRendering()) {
return;
}
[self renderer:renderer renderFrameForDistantView: self.videoMTKView];
}
});
}
-(void) renderer: (Video::Renderer*)renderer renderFrameForPreviewView:(CallMTKView*) view
-(void) renderer: (const lrc::api::video::Renderer*)renderer renderFrameForPreviewView:(CallMTKView*) view
{
@autoreleasepool {
auto framePtr = renderer->currentAVFrame();
......@@ -618,7 +584,7 @@ CVPixelBufferRef pixelBufferPreview;
}
}
-(void) renderer: (Video::Renderer*)renderer renderFrameForDistantView:(CallMTKView*) view
-(void) renderer: (const lrc::api::video::Renderer*)renderer renderFrameForDistantView:(CallMTKView*) view
{
@autoreleasepool {
auto framePtr = renderer->currentAVFrame();
......@@ -657,6 +623,8 @@ CVPixelBufferRef pixelBufferPreview;
createPool = true;
} else {
NSDictionary* atributes = (__bridge NSDictionary*)CVPixelBufferPoolGetAttributes(pixelBufferPoolPreview);
if(!atributes)
atributes = (__bridge NSDictionary*)CVPixelBufferPoolGetPixelBufferAttributes(pixelBufferPoolPreview);
int width = [[atributes objectForKey:(NSString*)kCVPixelBufferWidthKey] intValue];
int height = [[atributes objectForKey:(NSString*)kCVPixelBufferHeightKey] intValue];
if (width != frame->width || height != frame->height) {
......@@ -712,6 +680,8 @@ CVPixelBufferRef pixelBufferPreview;
createPool = true;
}
NSDictionary* atributes = (__bridge NSDictionary*)CVPixelBufferPoolGetPixelBufferAttributes(pixelBufferPoolDistantView);
if(!atributes)
atributes = (__bridge NSDictionary*)CVPixelBufferPoolGetPixelBufferAttributes(pixelBufferPoolDistantView);
int width = [[atributes objectForKey:(NSString*)kCVPixelBufferWidthKey] intValue];
int height = [[atributes objectForKey:(NSString*)kCVPixelBufferHeightKey] intValue];
if (width != frame->width || height != frame->height) {
......@@ -809,12 +779,9 @@ CVPixelBufferRef pixelBufferPreview;
{
if(self.splitView.isInFullScreenMode)
[self.splitView exitFullScreenModeWithOptions:nil];
QObject::disconnect(videoHolder.frameUpdated);
QObject::disconnect(videoHolder.started);
QObject::disconnect(videoHolder.stopped);
QObject::disconnect(previewHolder.frameUpdated);
QObject::disconnect(previewHolder.stopped);
QObject::disconnect(previewHolder.started);
QObject::disconnect(renderConnections.frameUpdated);
QObject::disconnect(renderConnections.started);
QObject::disconnect(renderConnections.stopped);
QObject::disconnect(self.messageConnection);
[self.chatButton setHidden:YES];
......@@ -1159,4 +1126,24 @@ CVPixelBufferRef pixelBufferPreview;
return YES;
}
-(void) screenShare {
NSScreen *mainScreen = [NSScreen mainScreen];
NSRect screenFrame = mainScreen.frame;
QRect captureRect = QRect(screenFrame.origin.x, screenFrame.origin.y, screenFrame.size.width, screenFrame.size.height);
mediaModel->setDisplay(0, screenFrame.origin.x, screenFrame.origin.y, screenFrame.size.width, screenFrame.size.height);
}
-(void) switchToDevice:(int)deviceID {
auto devices = mediaModel->getDevices();
auto device = devices[deviceID];
mediaModel->switchInputTo(device);
}
-(std::vector<std::string>) getDeviceList {
return mediaModel->getDevices();
}
-(void) switchToFile:(std::string)uri {
mediaModel->setInputFile(QUrl::fromLocalFile(uri.c_str()).toLocalFile().toStdString());
}
@end
......@@ -36,16 +36,6 @@
- (void)windowDidLoad {
[super windowDidLoad];
QObject::connect(CallModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
[composerField setStringValue:@""];
[composerField setNeedsDisplay:YES];
if(!current.isValid()) {
[self.window close];
}
});
}
- (IBAction)dtmfPressed:(id)sender
......@@ -66,11 +56,6 @@
- (void) sendDTMF:(NSString*) dtmf
{
if (auto current = CallModel::instance().selectedCall()) {
current->playDTMF(QString::fromUtf8([dtmf UTF8String]));
}
[composerField setStringValue:
[NSString stringWithFormat: @"%@ %@", [composerField stringValue], dtmf]];
}
///Accessibility
......
......@@ -81,7 +81,7 @@ static auto const kVideoPrefsIdentifer = @"VideoPrefsIdentifer";
{
[[prefsContainer subviews]
makeObjectsPerformSelector:@selector(removeFromSuperview)];
currentVC = [[AudioPrefsVC alloc] initWithNibName:@"AudioPrefs" bundle:nil];
currentVC = [[AudioPrefsVC alloc] initWithNibName:@"AudioPrefs" bundle:nil avModel: self.avModel];
[self resizeWindowWithFrame:currentVC.view.frame];
[prefsContainer addSubview:currentVC.view];
}
......@@ -132,4 +132,9 @@ static auto const kVideoPrefsIdentifer = @"VideoPrefsIdentifer";
return (frame.size.height - contentRect.size.height);
}
- (BOOL)windowShouldClose:(id)sender {
[self.window orderOut:self];
return NO;
}
@end
......@@ -29,7 +29,7 @@ namespace lrc {
}
}
@interface RingWindowController : NSWindowController <NSSharingServicePickerDelegate, ChooseAccountDelegate, LrcModelsProtocol, CallViewControllerDelegate> {
@interface RingWindowController : NSWindowController <NSSharingServicePickerDelegate, ChooseAccountDelegate, LrcModelsProtocol, CallViewControllerDelegate,NSWindowDelegate> {
IBOutlet NSView *currentView;
}
......
......@@ -103,6 +103,8 @@ typedef NS_ENUM(NSInteger, ViewState) {
self.dataTransferModel = dataTransferModel;
self.behaviorController = behaviorController;
self.avModel = avModel;
self.avModel->useAVFrame(YES);
avModel->deactivateOldVideoModels();
}
return self;
}
......@@ -137,6 +139,7 @@ typedef NS_ENUM(NSInteger, ViewState) {
[settingsVC hide];
break;
case SHOW_CALL_SCREEN:
self.avModel->useAVFrame(YES);
[self accountSettingsShouldOpen: NO];
if (![currentCallVC.view superview]) {
[callView addSubview:[currentCallVC view] positioned:NSWindowAbove relativeTo:nil];
......@@ -223,7 +226,6 @@ typedef NS_ENUM(NSInteger, ViewState) {
NSResponder * viewNextResponder = [self nextResponder];
[self setNextResponder: [conversationVC getMessagesView]];
[[conversationVC getMessagesView] setNextResponder: viewNextResponder];
self.avModel->useAVFrame(YES);
}
- (void) connect
......@@ -240,7 +242,8 @@ typedef NS_ENUM(NSInteger, ViewState) {
[currentCallVC setCurrentCall:convInfo.callId
conversation:convInfo.uid
account:accInfo];
account:accInfo
avModel: avModel];
[self changeViewTo:SHOW_CALL_SCREEN];
});
......@@ -257,7 +260,8 @@ typedef NS_ENUM(NSInteger, ViewState) {
[currentCallVC setCurrentCall:convInfo.callId
conversation:convInfo.uid
account:accInfo];
account:accInfo
avModel: avModel];
[smartViewVC selectConversation: convInfo model:accInfo->conversationModel.get()];
[self changeViewTo:SHOW_CALL_SCREEN];
});
......@@ -589,7 +593,8 @@ typedef NS_ENUM(NSInteger, ViewState) {
}